[英]can not upload zip file with php
i am trying to upload a zip file with php. 我正在尝试使用php上传一个zip文件。 but it is not uploaded to temporary folder..when i am printing the $_FILES array in the posted action , values of fields type,tmp_name becomes null and error field becomes 1 .which means file not uploaded to temporary folder... but uploading of image files becomes success..this issue is only in the case of zip files..can anyone help me please.
但是它没有上传到临时文件夹..当我在发布的操作中打印$ _FILES数组时,字段type,tmp_name的值变为null,并且错误字段变为1。这意味着文件未上传到临时文件夹...而是上传的图像文件成功。.这个问题仅在zip文件的情况下..任何人都可以帮帮我。
here is the code 这是代码
encrypt-zip-file.phtml crypto-zip-file.phtml
<form action="<?php echo $this->basePath() ?>/encrypt-zip-file" method="post"enctype="multipart/form-data">
Select zip file to upload:
<input type="file" name="fileToUpload" id="fileToUpload">
<input type="submit" value="Upload" name="submit">
</form>
code in the action 动作中的代码
$target_dir = $_SERVER['DOCUMENT_ROOT']."/zip_files/";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
$uploadOk = 1;
move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file);
Php does not restrict file upload types. PHP不限制文件上传类型。 All the file types are supported.
支持所有文件类型。
But there are certain configuration related to uploads like file_upload, max_file_uploads, upload_max_filesize 但是有些与上传相关的配置,例如file_upload,max_file_uploads,upload_max_filesize
It could be possible that the zip file is going beyond the allowed limit. 压缩文件可能超出了允许的限制。
http://en.wikipedia.org/wiki/Internet_media_type http://en.wikipedia.org/wiki/Internet_media_type
There might be any problem in page in which you might be encrypting that zip 页面中可能存在任何问题,您可能正在其中加密该zip文件
the code i have tried works like charm and it is as below 我尝试过的代码就像魅力一样工作,如下所示
<?php if($_POST){ $target_dir = $_SERVER['DOCUMENT_ROOT']; $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]); $uploadOk = 1; move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file); } ?> <form action="index.php" method="post"enctype="multipart/form-data"> Select zip file to upload: <input type="file" name="fileToUpload" id="fileToUpload"> <input type="submit" value="Upload" name="submit"> </form>
if it still doesn't work then check configuration parameters such as file_upload, max_file_uploads, upload_max_filesize in php.ini file 如果仍然无法使用,请检查php.ini文件中的配置参数,例如file_upload,max_file_uploads,upload_max_filesize
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.