PHP上传文件错误代码8

时间:2015-08-07 12:55:12

标签: php upload

我有一张表格可以很好地上传(上传)许多图像文件并且尺寸不同。

但有些图片未上传到服务器。

问题图片已空 $ _ FILE [名称] [tmp_name] $ _ FILE [名称] [错误] == 8.

同时正确上传其他图片(文件大小更大或更小)。

你有什么想法吗?


感谢。

print_r($_FILES) for normal image

FILES:Array
(
    [img] => Array
        (
            [name] => Array
                (
                    [0] => 1320600215_0_284da_78d5c77a_xl.jpg
                )

            [type] => Array
                (
                    [0] => image/jpeg
                )

            [tmp_name] => Array
                (
                    [0] => /var/www/test/data/mod-tmp/phpoqm4qR
                )

            [error] => Array
                (
                    [0] => 0
                )

            [size] => Array
                (
                    [0] => 126867
                )

        )

)



print_r($_FILES) for problem image
FILES:Array
(
    [img] => Array
        (
            [name] => Array
                (
                    [0] => 94689121_1GPPZgCqPmI.jpg
                )

            [type] => Array
                (
                    [0] => 
                )

            [tmp_name] => Array
                (
                    [0] => 
                )

            [error] => Array
                (
                    [0] => 8
                )

            [size] => Array
                (
                    [0] => 0
                )

        )

)

2 个答案:

答案 0 :(得分:0)

嗨错误代码8表示:

 UPLOAD_ERR_EXTENSION

    Value: 8; A PHP extension stopped the file upload. PHP does not provide a way to ascertain which extension caused the file upload to stop; examining the list of loaded extensions with phpinfo() may help. Introduced in PHP 5.2.0.

可能会有所帮助的事情:

  1. 检查您的服务器是否安装了一些可能限制文件上传的额外安全模块(例如.Shosin提出了很多这些问题)

  2. 检查您的max_upload_filesize和post_max_size参数是否已正确设置

  3. 尝试检查某个特定文件是否会出现此问题(例如,大文件,某些扩展名或某些文件名)或者是否完全随机

答案 1 :(得分:0)

            if (isset($_FILES['files']) && !empty($_FILES['files'])) 
             {
                  date_default_timezone_set("asia/kolkata");
                  $image=date("YmdHis")."_".$_FILES['files']['name'];
                  move_uploaded_file($_FILES['files'] 
                  ['tmp_name'],"uploads/business/".$image);
             }