Kha*_*nia 5 php file-upload yii yii-extensions dropzone.js
我正在使用 Yii 框架的 dropzone 扩展来由注册用户上传一些文件。一切正常,但有些用户尝试上传某些文件时返回错误 = 3,当上传的文件仅部分上传时会发生这种情况。
$file_error = $_FILES['Project']['error']['file'];
if ($file_error != 0) {
mail('myemail@gmail.com', 'fileError',json_encode($_FILES['Project']));
}
Run Code Online (Sandbox Code Playgroud)
我收到了很多来自此功能的电子邮件
收到 JSON
{"name":{"file":"3.jpg"},"type":{"file":""},"tmp_name":{"file":""},"error":{"file":3},"size":{"file":0}}
Run Code Online (Sandbox Code Playgroud)
发生此错误 1- 如果用户在上传时刷新页面。2- 如果用户取消上传(我的网站中没有取消选项)。3- 如果在上传时互联网连接丢失。
我还在寻找其他案例。
正如 php 文档所说,这个错误是
UPLOAD_ERR_PARTIAL is given when the mime boundary is not found after the file data.
A possibly cause for this is that the upload was cancelled by the user (pressed ESC, etc).
还有更多变体需要检查:
权限是错误的(我怀疑,因为它会破坏所有用户)。
服务器上没有足够的可用空间。
从 iOS 上传时会出现此错误。
上传文件夹时可能会出现此错误(由于浏览器限制)。在 Mac OSX 上,这种情况 100% 发生。
所以这是需要检查的可能错误。希望这会有所帮助。