Yii COCO extension


(Boulanger Nico1) #1

Bonsoir, j’utilise l’extension coco afin d’upload un fichier texte sur mon serveur , l’extension est opérationnelle a pars le fait que lors de l’upload il m’affiche : Upload fail, quelqu’un serrais au courant de comment marche cet extension ?


(Boulanger Nico1) #2

Ma vue :


 <?php

    $this->widget('ext.coco.CocoWidget'

        ,array(

            'id'=>'cocowidget1',

            'onCompleted'=>'function(id,filename,jsoninfo){  }',

            'onCancelled'=>'function(id,filename){ alert("cancelled"); }',

            'onMessage'=>'function(m){ alert(m); }',

            'allowedExtensions'=>array('txt'), // server-side mime-type validated

            'sizeLimit'=>2000000, // limit in server-side and in client-side

            'uploadDir' => 'assets/', // coco will @mkdir it

            // this arguments are used to send a notification

            // on a specific class when a new file is uploaded,

            'receptorClassName'=>'application.models.Licence',

            'methodName'=>'myFileReceptor',

            //'userdata'=>$model->primaryKey,

            // controls how many files must be uploaded

            'maxUploads'=>1, // defaults to -1 (unlimited)

            'maxUploadsReachMessage'=>'No more files allowed', // if empty, no message is shown

            // controls how many files the can select (not upload, for uploads see also: maxUploads)

            'multipleFileSelection'=>false, // true or false, defaults: true

        	'buttonText'=>'Find & Upload',

        	'dropFilesText'=>'Drop Files Here !',

        	'defaultControllerName'=>'Licence',

        	'defaultActionName'=>'Maj',

        ));

    ?>

Mon model :


<?php 


class Licence extends CocoWidget {

	public function myFileReceptor($fullFileName,$userdata) {

		

		$this->actionMaj($fullFileName);

		

	}

}



Mon controlleur :


<?php


class LicenceController extends Controller {

    

	public function actionMaj($fullFileName)

	{

          if (isset($fullFileName))

          {

            rename("../../licence/Licence_Capflor.txt","../../licence/Old_Licence_Capflor.txt");

            

          if ($files->saveAs($fullFileName))

          {

           	Yii::app()->user->setFlash('msg','La licence à étais sauvegardé avec succès');

           	

           	Yii::app()->db->createCommand()->update('users', array('licence_acceptee'=>'false'),

           			'username=:username', array(':username'=>'*'));

          }

          else{

          	Yii::app()->user->setFlash('msg','Une erreur à empeché la sauvegarde de la licence');

          }

          

          if(!$model->save())

          {

         	Yii::app()->user->setFlash('msg','File not save in BD');

          }

     	   

          $this->render('majLicence');

	} 

}

}



Ps: petit up au passage, ca serait cool que quelqu’un arrive a m’aider