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.