我想使用eajaxupload擴展來處理文件在我的網站上傳。我完全按照指令here,遇到了一個問題:每次我上傳一個有效的文件時都失敗(對無效文件的驗證效果很好)。我GOOGLE了它,發現一個可能的解決方案here,但我沒有成功。 這是在我的控制器:Eajaxupload每次顯示「失敗」
public function actionUpload() {
Yii::import("ext.EAjaxUpload.qqFileUploader");
$folder='upload/';// folder for uploaded files
$allowedExtensions = array("zip","rar","7z");//array("jpg","jpeg","gif","exe","mov" and etc...
$sizeLimit = 5 * 1024 * 1024;// maximum file size in bytes
$uploader = new qqFileUploader($allowedExtensions, $sizeLimit);
$result = $uploader->handleUpload($folder);
$return = htmlspecialchars(json_encode($result), ENT_NOQUOTES);
$fileSize=filesize($folder.$result['filename']);//GETTING FILE SIZE
$fileName=$result['filename'];//GETTING FILE NAME
echo $return;// it's array
}
這是我的看法:
$this->widget('ext.EAjaxUpload.EAjaxUpload',
array(
'id'=>'uploadFile',
'config'=>array(
'action'=>$this->createUrl('ProjectController/upload'),
'allowedExtensions'=>array("zip","rar","7z"),//array("jpg","jpeg","gif","exe","mov" and etc...
'sizeLimit'=>5*1024*1024,// maximum file size in bytes
//'minSizeLimit'=>10*1024*1024,// minimum file size in bytes
//'onComplete'=>"js:function(id, fileName, responseJSON){ alert(fileName); }",
//'messages'=>array(
// 'typeError'=>"{file} has invalid extension. Only {extensions} are allowed.",
// 'sizeError'=>"{file} is too large, maximum file size is {sizeLimit}.",
// 'minSizeError'=>"{file} is too small, minimum file size is {minSizeLimit}.",
// 'emptyError'=>"{file} is empty, please select files again without it.",
// 'onLeave'=>"The files are being uploaded, if you leave now the upload will be cancelled."
// ),
//'showMessage'=>"js:function(message){ alert(message); }"
)
));
請告訴我,如果我出了問題的地方。
請爲提問者提供更多詳情 – Sid 2012-12-21 12:49:53