问题
My Question is: "Does move_uploaded_file()
automatically deletes the temporary uploaded file after successful move ?"
Just to get out of the confusion that do i need to do this:
// Successful upload
if ( move_uploaded_file($file['tmp_name'], $destination) ) {
unlink($file['tmp_name']);
return TRUE;
} else {
// Upload Failed
unlink($file['tmp_name']);
return FALSE;
}
Or is it not needed at all?
回答1:
You do not need to manually unlink()
the temporary file; PHP cleans up after itself after a successful upload. The function is called move_uploaded_file, not copy_uploaded_file.
回答2:
Yes, it does.
http://php.net/manual/en/function.move-uploaded-file.php
Function description: 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.
So we see here:
If the file is valid, it will be moved to the filename given by destination.
回答3:
Temporary File is Deleted Automatically. You dont have to delete it manually. move_uploaded_file
function also not delete this temporary file.
来源:https://stackoverflow.com/questions/13840951/does-move-uploaded-file-automatically-deletes-the-temporary-uploaded-file-afte