Php 3 file upload error code

Downloading a larger file (> 10KB) will receive error code 3(UPLOAD_ERR_PARTIAL) in $_FILES['file']['error'], and a small file (<10KB) will be downloaded successfully.

If the file exceeds the php limit post_max_size or upload_max_filesize , it should receive error code 1 UPLOAD_ERR_INI_SIZE. However, the receipt error code 3 UPLOAD_ERR_PARTIAL is incorrect .

I assume that he has something wrong with the apache configuration, and I don’t know how to solve this problem.

Using below software and its versions

  • php 5.6.17
  • apache 2.4.18

Below is the symbol php.ini:

post_max_size = 8M
file_uploads = On
upload_tmp_dir = "/tmp"
upload_max_filesize = 2M

and when loading a 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 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 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']);
}
?>
+4
1

FreeBSD 10.1 php 5.6.18 apache 2.4.18: 7950 3, , .

, , : PHP- (mod_php56) apache2filter SAPI, AddHandler. mod_php56 ( AP2FILTER).

. , OPTIONS_FILE_SET+=AP2FILTER (Apache 2 Filter SAPI), PHP (AddType application/x-httpd-php .php). ( /), mod_php56 .

, , php_sapi_name(). apache2filter, php AddHandler, . php_sapi_name() apache2handler. phpinfo(), " Apache 2.0" " Apache 2.0" .

, , ( Handler ). , mod_php , .

+7

Source: https://habr.com/ru/post/1625933/


All Articles