Forum Moderators: coopster

Message Too Old, No Replies

copy OR move_uploaded_file

which function to use?

         

scriptmasterdel

2:57 pm on May 10, 2006 (gmt 0)

10+ Year Member



Which one should i use? copy() OR move_uploaded_file()

Please post reasons why!

jatar_k

3:03 pm on May 10, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



unless you need a copy of it in it's original position then you should just use move_uploaded_file

siMKin

3:19 pm on May 10, 2006 (gmt 0)

10+ Year Member



Which one should i use? copy() OR move_uploaded_file()

[php.net...]

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.

Note: move_uploaded_file() is both safe mode and open_basedir aware. However, restrictions are placed only on the destination path as to allow the moving of uploaded files in which filename may conflict with such restrictions. move_uploaded_file() ensures the safety of this operation by allowing only those files uploaded through PHP to be moved.