【发布时间】:2015-06-10 17:22:40
【问题描述】:
我正在使用带有 Yii 的 blueimp 文件上传插件来尝试将文件上传到我的服务器(当前为 localhost)。我给了文件夹完整的读/写权限(位置是 C:\xampp\htdocs\yii),但是当我尝试执行 move_uploaded 文件命令时仍然出现错误。
这里是主窗体和输入文件区:
<form id='upload' method='post' action='?r=site/move' enctype='multipart/form-data' style="padding:0;">
<span class="btn fileinput-button" style="padding:0">
<i class="glyphicon glyphicon-picture">
<input id="fileupload" type="file" accept="image/*" name="attachment" onchange="attachAttachment()">
</i>
</span>
</form>
这是 blueimp 的文件上传(在 function() 中):
$("#fileupload").fileupload
({
dataType: 'json',
done: function (e, data)
{
console.log("YAY");
},
fail: function(e, data)
{
console.log("FAIL");
}
});
这是actionMove,我将文件从临时目录移动到文件夹:
public function actionMove()
{
if (isset($_FILES['attachment']) && $_FILES['attachment']['error'] == 0)
{
if (move_uploaded_file($_FILES['attachment'], Yii::getPathOfAlias('webroot')."/images/uploads")){
$response = '{"status":"success"}';
}
else {
$response = '{"status":"error"}';
}
echo $response;
exit();
}
}
我已经在这几个小时了,感谢任何帮助:(
【问题讨论】: