Yii Framework Forum: Yii COCO extension - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Yii COCO extension Rate Topic: -----

#1 User is offline   Niko_Yii 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 21-March 17

Posted 21 March 2017 - 11:18 AM

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 ?
0

#2 User is offline   Niko_Yii 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 21-March 17

Posted 22 March 2017 - 08:26 AM

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
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users