hi,
just want to find out when to use copy() and when to use move_uploaded_file() when uploading files to the server.
how about is_uploaded_file() ?
thanks
copy() vs move_upload file()
Moderator: General Moderators
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Have a look at the docs:
copy() -
http://www.php.net/manual/en/features.file-upload.php
move_uploaded_files() means instead of doing this:
you can just do this:
Mac
copy() -
move_uploaded_file() -Makes a copy of a file. Returns TRUE if the copy succeeded, FALSE otherwise.
So if you're uploading files to the server using PHP's HTTP POST upload mechanism use move_uploaded_files(), if you're not and need to copy a file use copy().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.
http://www.php.net/manual/en/features.file-upload.php
move_uploaded_files() means instead of doing this:
Code: Select all
if (is_uploaded_file($_FILESї'userfile']ї'tmp_name'])) {
copy($_FILESї'userfile']ї'tmp_name'], "/place/to/put/uploaded/file");
}Code: Select all
move_uploaded_file($_FILESї'userfile']ї'tmp_name'], "/place/to/put/uploaded/file");