PhP - move_uploaded_file()废话

时间:2015-10-15 20:23:39

标签: php

代码:

    echo $tmpName;
    echo "<br>". "{$uploadDir}/{$folderName}/{$fileName}";
    echo'<pre>';var_dump(file_exists("{$uploadDir}/{$folderName}"));echo'</pre>';
    echo'<pre>';var_dump(move_uploaded_file($tmpName, "{$uploadDir}/{$folderName}/{$fileName}"));echo'</pre>';
    echo substr(sprintf('%o', fileperms("{$uploadDir}/{$folderName}")), -4);     echo "<br>";


    if(move_uploaded_file($tmpName, "{$uploadDir}/{$folderName}/{$fileName}")) {
        $sqlup = "INSERT INTO upload_obrazky (slozka_upload_obrazky, pic_upload_obrazky) VALUES ('".$folderName."', '".$fileName."')";
        mysql_query( $sqlup );
        ++$counter;
    }  

输出:

Tempname:

/tmp/phpH9a6xK

真实档案&amp;文件夹:

../files/upload/834e4315ebd644ac5bd0569af73a9cf1/akne.jpg

文件夹存在吗?

bool(true)

移动上传的文件?? !!?!??!?!?!?!??!?!?!?!?!?!?!?!?!

bool(false)

目录上的Chmod:

0777

有人可以告诉我为什么move_uploaded_file() FALSE ?谢谢你们。

1 个答案:

答案 0 :(得分:3)

您正试图将上传的文件移动两次

echo'<pre>';var_dump(move_uploaded_file($tmpName, "{$uploadDir}/{$folderName}/{$fileName}"));echo'</pre>';

在这里:

if(move_uploaded_file($tmpName, "{$uploadDir}/{$folderName}/{$fileName}")) {