PHP不上传超过55 kb的文件

时间:2014-07-19 11:11:04

标签: php file upload

超过50 KB的文件未上传。我检查了php.ini,我有以下值

post_max_size = 16M (which i have increased from 3 MB but still no luck)
upload_max_filesize = 64M
max_file_uploads = 20

我已经尝试过阅读所有内容,无法找到解决方案,如果有人遇到同样的问题,请分享您的经验。

PHP:

if(isset($_FILES["file"]))
{
    if($_FILES["file"]["error"] == 0)
    {
        $uploaded_file_name =  $_FILES["file"]["name"];
        move_uploaded_file($_FILES["file"]['tmp_name'], __DIR__ . "/" . $uploaded_file_name);
        exit;
    }
}

HTML:

<form action="<?php $_SERVER["PHP_SELF"] ?>" method="post" enctype="multipart/form-data">
    <label for="file">Filename:</label>
    <input type="file" name="file" id="file"><br>
    <input type="submit" name="submit" value="Submit">
</form>

1 个答案:

答案 0 :(得分:1)

post_max_size必须等于或大于upload_file_size

示例

 ; Maximum allowed size for uploaded files.
 upload_max_filesize = 64M

 ; Must be greater than or equal to upload_max_filesize  
 post_max_size = 64M