开发者

Retrieving files from POST

Hey, I've got a php script to take the contents of the $_FILES array, run it through various checks, to ensure 开发者_运维百科its the correct file. Once the checks have been passed, I want the program to copy the file into some static directory so I can then process it as desired.

Basically, the code using move_uploaded_files isnt working for me, here is a snippet of my code.

    $uploads_dir = $_SERVER['DOCUMENT_ROOT'] . '/uploads/';

    if (move_uploaded_file($_FILES['temp_signupXML']['tmp_name'],$uploads_dir . $_FILES['temp_signupXML']['name'])) echo "\n MOVED - Successful";
    else{
        echo "\n MOVED - Failed!";
    }


Make sure you have the write permissions on the uploads directory.


From the PHP Manual:

Returns TRUE on success.

If filename is not a valid upload file, then no action will occur, and move_uploaded_file() will return FALSE.

If filename is a valid upload file, but cannot be moved for some reason, no action will occur, and move_uploaded_file() will return FALSE. Additionally, a warning will be issued.

So essentially, if a warning is issued, your problem either lies in the fact that the uploads directory does not exist or the uploads directory does not have sufficient permissions to allow PHP to write to it. If no warning is issued, then the file isn't being uploaded properly.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜