Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does move_uploaded_file() automatically deletes the temporary uploaded file after SUCCESSful Move?

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?

like image 763
Ronnie Depp Avatar asked Dec 12 '12 13:12

Ronnie Depp


1 Answers

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.

like image 145
Martin Bean Avatar answered Oct 09 '22 15:10

Martin Bean