Efineuploader Help

Hi there,

I’m trying to get the EFineUploader Extension to work and need some help.

The model I want to use it in is called ‘Property’

And I’ve created a folder to put uploaded files into at localhost/myApp/images/uploads

This is the code I have in _form.php:


 $this->widget('ext.EFineUploader.EFineUploader',

 array(

       'id'=>'FineUploader',

       'config'=>array(

                       'autoUpload'=>true,

                       'request'=>array(

                          'endpoint'=>'/property/upload',// OR $this->createUrl('property/upload'),

                          'params'=>array('YII_CSRF_TOKEN'=>Yii::app()->request->csrfToken),

                                       ),

                       'retry'=>array('enableAuto'=>true,'preventRetryResponseProperty'=>true),

                       'chunking'=>array('enable'=>true,'partSize'=>100),//bytes

                       'callbacks'=>array(

                                        'onComplete'=>"js:function(id, name, response){  }",

                                        'onError'=>"js:function(id, name, errorReason){ }",

                                         ),

                       'validation'=>array(

                                 'allowedExtensions'=>array('jpg','jpeg'),

                                 'sizeLimit'=>2 * 1024 * 1024,//maximum file size in bytes

                                 //'minSizeLimit'=>2*1024*1024,// minimum file size in bytes

                                          ),

                      )

      ));

And this is in PropertyController.php:


public function actionUpload()

        {

                $tempFolder=Yii::getPathOfAlias('webroot').'/images/uploads/';

 

                mkdir($tempFolder, 0777, TRUE);

                mkdir($tempFolder.'chunks', 0777, TRUE);

 

                Yii::import("ext.EFineUploader.qqFileUploader");

 

                $uploader = new qqFileUploader();

                $uploader->allowedExtensions = array('jpg','jpeg');

                $uploader->sizeLimit = 2 * 1024 * 1024;//maximum file size in bytes

                $uploader->chunksFolder = $tempFolder.'chunks';

 

                $result = $uploader->handleUpload($tempFolder);

                $result['filename'] = $uploader->getUploadName();

                $result['folder'] = $webFolder;

 

                $uploadedFile=$tempFolder.$result['filename'];

 

                header("Content-Type: text/plain");

                $result=htmlspecialchars(json_encode($result), ENT_NOQUOTES);

                echo $result;

                Yii::app()->end();

        }

The Upload File button renders fine and I can select an image to upload but I just get the upload failed message. Any help would be greatly appreciated.

Thanks in advance.

I am trying very hard and stuck just as you do. After many try and error, I managed to get it to work although still not perfect. Here is what you should do

Comment out




                mkdir($tempFolder, 0777, TRUE);

                mkdir($tempFolder.'chunks', 0777, TRUE);



and




                $result['folder'] = $webFolder;



The reason is because these lines of code will throw a warning and hence will halt the execution of the script.

Next, you have to go to your webroot, create a folder call upload and inside the folder upload, create 2 folders call temp and chunks respectively

Now go back and try to upload again

For anyone else who might step into the same trap as is did :)

In the widget it has to be:


[...]'chunking'=>array('enabled'=>true[...]

not:


[...]'chunking'=>array('enable'=>true[...]

as it is in the example on the extension-page.

There are many reasons that lead to your error.

  • folder permission (777)

  • utf-8 filename

  • cookie modify header if you call this afterload

  • multiple call causes duplicate js variable.

-…

Hope this could help.