Jump to content

copy() VS move_uploaded_file


robert_gsfame

Recommended Posts

From the php manual for the move_uploaded_file function:

This function checks to ensure that the file designated by filename is a valid upload file (meaning that it was uploaded via PHP's HTTP POST upload mechanism). If the file is valid, it will be moved to the filename given by destination.

 

This sort of check is especially important if there is any chance that anything done with uploaded files could reveal their contents to the user, or even to other users on the same system.

 

'valid uploaded file' = php runs the is_uploadedfile function within move_uploaded_file function. So mainly the move_uploaded_file is better when you want to move an uploaded file, cause security issues.

Link to comment
Share on other sites

Again from php manuals:

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, please...  :rtfm:

http://php.net/manual/en/function.move-uploaded-file.php

Link to comment
Share on other sites

Oops one more question, i got the error when checking whether file has been copy into the folder using copy()...i cant solve this problem yet, so i decided to use move_uploaded_file to avoid the error...

 

why cant i get the return value "TRUE" of "FALSE" use copy() so that the error appeared...it seems like copy() cannot read my filename...??

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.