$_FILE upload large file gives error 1 even though upload_max_size is bigger than the file size

北慕城南 提交于 2019-11-28 06:19:38

I think this is because of a typo. Instead of

upload_max_filesize = 7MB

it should read

upload_max_filesize = 7M

use phpinfo() again to check what value actually gets applied.

Lawrence

You also have to set the post_max_size in "php.ini"

yasin
upload_max_filesize = 7M

Here the value is like 7M or 10M but not MB.

Use phpinfo() again to check what value actually got applied.

Use the code below to understand what the problem is. If file size is the problem, it simply prints out put as exceeds the upload_max_filesize directive in php.ini

<?php
$error_types = array(
    1 => 'The uploaded file exceeds the upload_max_filesize directive in php.ini.',
    'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.',
    'The uploaded file was only partially uploaded.',
    'No file was uploaded.',
    6 => 'Missing a temporary folder.',
    'Failed to write file to disk.',
    'A PHP extension stopped the file upload.'
);

// Outside a loop...
if ($_FILES['userfile']['error'] == 0) {
    // here userfile is the name
    // i.e(<input type="file" name="*userfile*" size="30" id="userfile">
    echo "no error ";
} else {
    $error_message = $error_types[$_FILES['userfile']['error']];
    echo $error_message;
}
?>

By this we can easily identify the problem. We can also use switch(){ case } to print the above error messages.

pdschubert

Here is a big mistake I've done:

If you want to upload really big files, you have to set KeepAliveTimeout higher than the 5 seconds default value.

For example:

KeepAliveTimeout 300

You can find this property in /etc/apache2/apache2.conf

nisam

goto WHM->Service Configuration->PHP Configuration Editor and update the value of upload_max_filesize.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!