【发布时间】:2013-02-12 12:26:30
【问题描述】:
我在 yii 中尝试 ti 用户 eajaxupload 扩展(使用这篇文章:http://www.yiiframework.com/extension/eajaxupload
我想将图像上传并附加到控制器之一, 我试试这段代码: 在控制器中: *(我的控制器名称是:文章)*
public function actionUpload()
{
Yii::import("ext.EAjaxUpload.qqFileUploader");
$folder= Yii::app()->baseUrl .'/uploads';// folder for uploaded files
$allowedExtensions = array("jpg");//array("jpg","jpeg","gif","exe","mov" and etc...
$sizeLimit = 10 * 1024 * 1024;// maximum file size in bytes
$uploader = new qqFileUploader($allowedExtensions, $sizeLimit);
$result = $uploader->handleUpload($folder);
$result=htmlspecialchars(json_encode($result), ENT_NOQUOTES);
$fileSize=filesize($folder.$result['filename']);//GETTING FILE SIZE
$fileName=$result['filename'];//GETTING FILE NAME
//echo $result;// it's array
}
在 _form.php(用于控制器)中我有:
$this->widget('ext.EAjaxUpload.EAjaxUpload',
array(
'id'=>'uploadFile',
'config'=>array(
'action'=>'/article/upload',
'allowedExtensions'=>array("jpg"),//array("jpg","jpeg","gif","exe","mov" and etc...
'sizeLimit'=>10*1024*1024,// maximum file size in bytes
//'minSizeLimit'=>10*1024*1024,// minimum file size in bytes
//'onComplete'=>"js:function(id, fileName, responseJSON){ alert(fileName); }",
'showMessage'=>"js:function(message){ alert(message); }"
)
)); ?>
上传文件夹对所有人具有完全访问权限!, 但是当我推送上传文件并选择一个文件时总是出错:文件名,文件大小和失败!
我的代码有什么问题?
【问题讨论】:
标签: upload yii-extensions