Upload bigger file( > 10KB) will get error code 3(UPLOAD_ERR_PARTIAL) in $_FILES['file']['error']
and small file( < 10KB) will upload successfully.
If the file exceed the limit php post_max_size or upload_max_filesize, it should get error code 1 UPLOAD_ERR_INI_SIZE
. However, getting error code 3 UPLOAD_ERR_PARTIAL
which is incorrect.
I guess it has something wrong with apache setting, and have no idea how to solve this problem.
Using below software and its versions
- php 5.6.17
- apache 2.4.18
Following is the php.ini
:
post_max_size = 8M
file_uploads = On
upload_tmp_dir = "/tmp"
upload_max_filesize = 2M
and when upload larger file(hi.png) the error log in /var/log/httpd-error.log
PHP Notice: Missing mime boundary at the end of the data for file hi.png in Unknown on line 0
here are index.php
<!DOCTYPE html>
<html>
<body>
<form action='upload.php' method='post' enctype='multipart/form-data'>
Select image to upload:
<input type='file' name='fileToUpload' id='fileToUpload'>
<input type='submit' value='Upload Image' name='submit'>
</form>
</body>
</html>
and the upload.php
<?php
if($_FILES['fileToUpload']['error'] > 0){
echo "error code".$_FILES['fileToUpload']['error']."<br>";
}
else{
echo "file name:".$_FILES['fileToUpload']['name']."<br>";
echo "file type:".$_FILES['fileToUpload']['type']."<br>";
echo "file size:".$_FILES['fileToUpload']['size']."<br>";
echo "file path:".$_FILES['fileToUpload']['tmp_name']."<br>";
move_uploaded_file($_FILES['fileToUpload']['tmp_name'],"uploads/".$_FILES['fileToUpload']['name']);
}
?>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…