move_uploaded_file不工作,没有错误,is_uploaded_file()返回true

时间:2013-06-19 13:42:23

标签: php is-uploaded-file

我疯了,因为设置了enctype,一切都像我一直都这样。

这是PHP:

        $allowedExts = array("jpeg", "jpg", "JGP", "JPEG");
        $temp = explode(".", $_FILES[$parsed['img']]["name"]);
        $extension = end($temp);
        print_r($_FILES);
        if(is_uploaded_file($_FILES[$parsed['img']]["tmp_name"]) && $_FILES[$parsed['img']]["size"] < 200000 && ($_FILES[$parsed['img']]["type"] == "image/jpeg") || ($_FILES[$parsed['img']]["type"] == "image/jpg") && in_array($extension, $allowedExts)){
            if ($_FILES[$parsed['img']]["error"] > 0){
                echo "Error: " . $_FILES[$parsed['img']]["error"] . "<br>";
            } else {
                //echo "Upload: " . $_FILES[$parsed['img']]["name"] . "<br>";
                //echo "Type: " . $_FILES[$parsed['img']]["type"] . "<br>";
                //echo "Size: " . ($_FILES[$parsed['img']]["size"] / 1024) . " kB<br>";
                //echo "Stored in: " . $_FILES[$parsed['img']]["tmp_name"];
                if(file_exists("./" . $_FILES[$parsed['img']]["name"])){
                    echo $_FILES[$parsed['img']]["name"] . " already exists. ";
                } else {
                    echo $_FILES[$parsed['img']]['tmp_name'];
                    move_uploaded_file($_FILES[$parsed['img']]["name"], "./" . $_FILES[$parsed['img']]["name"]);

                }
            }
        } else {
            echo "Invalid file";
        }

这是print_r给我的:

Array
(
[0-image] => Array
    (
        [name] => p4pb9513672.jpg
        [type] => image/jpeg
        [tmp_name] => C:\xampp\tmp\php4D1C.tmp
        [error] => 0
        [size] => 141012
    )

[1-image] => Array
    (
        [name] => 
        [type] => 
        [tmp_name] => 
        [error] => 4
        [size] => 0
    )

[2-image] => Array
    (
        [name] => 
        [type] => 
        [tmp_name] => 
        [error] => 4
        [size] => 0
    )

[3-image] => Array
    (
        [name] => 
        [type] => 
        [tmp_name] => 
        [error] => 4
        [size] => 0
    )

[4-image] => Array
    (
        [name] => 
        [type] => 
        [tmp_name] => 
        [error] => 4
        [size] => 0
    )

[5-image] => Array
    (
        [name] => 
        [type] => 
        [tmp_name] => 
        [error] => 4
        [size] => 0
    )

[6-image] => Array
    (
        [name] => 
        [type] => 
        [tmp_name] => 
        [error] => 4
        [size] => 0
    )

[7-image] => Array
    (
        [name] => 
        [type] => 
        [tmp_name] => 
        [error] => 4
        [size] => 0
    )

$ parsed ['img']包含'0-image',并且回显$ _FILES [$ parsed ['img']] ['tmp_name']向我显示与print_r相同的tmp_name,因此它会检出。< / p>

不起作用,没有错误,没有,is_uploaded_file返回true。

疯了。

0 个答案:

没有答案