[英]PHP: Cannot upload ZIP Files
Whenever I try to upload a ZIP File via PHP, the Filesize is 0. 每当我尝试通过PHP上传ZIP文件时,Filesize为0。
Everything else works: 7z, rar, png, xml 其他所有工作:7z,rar,png,xml
for example (I output filesize and location for testing): 例如(我输出filesize和location进行测试):
File Location: /tmp/phpKNortG/feba81fed1ff5d2c04aa0c42975eb94f.7z
Filesize: 1284
File Location: /tmp/phpEWrmLT/feba81fed1ff5d2c04aa0c42975eb94f.zip
Filesize: 0
My form has enctype="multipart/form-data"
and the file is definitely not too big to be uploaded. 我的表单有
enctype="multipart/form-data"
,文件肯定不会太大而无法上传。 (I've also set the memory limit to 128 MB to make sure it's not that) (我还将内存限制设置为128 MB,以确保它不是那样)
ini_set('memory_limit', '128M');
set_time_limit(0);
$session_id = "3423840093480344";
mkdir('uploaded_files/' . $session_id);
for($i = 0; $i < count($_FILES['backup_file']['name']); $i++) {
$file_name = $_FILES['backup_file']['name'][$i];
$file_type = $_FILES['backup_file']['type'][$i];
$file_error = $_FILES['backup_file']['error'][$i];
$file_size = $_FILES['backup_file']['size'][$i];
$file_tmp = $_FILES['backup_file']['tmp_name'][$i];
print($file_name . "<br />");
print($file_type . "<br />");
print($file_error . "<br />");
print($file_size . "<br />");
print($file_tmp . "<br />");
if($file_error != 0) {
echo "Error-Code: ".$file_error;
continue;
}
move_uploaded_file($file_tmp, 'uploaded_files/' . $session_id);
}
The following code outputs this: 以下代码输出:
feba81fed1ff5d2c04aa0c42975eb94f.zip
application/zip
0
0
/tmp/phpEWrmLT
It even recognizes the MIME-Type, but the file is always zero bytes in size. 它甚至可以识别MIME-Type,但文件的大小始终为零字节。 (even before moving it with move_uploaded_file)
(甚至在用move_uploaded_file移动它之前)
Is there any server setting that could prevent .zip files to be uploaded? 是否有任何服务器设置可以阻止.zip文件上传?
The memory_limit setting has no bearing on file uploads. memory_limit设置与文件上载无关。
What are the values for your post_max_size and upload_max_filesize and how does the .zip filesize compare with those values? post_max_size和upload_max_filesize的值是什么?.zip文件大小与这些值的比较如何?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.