本文介绍了move_uploaded_file()会在SUCCESSful Move后自动删除临时上传的文件吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是:$ move_uploaded_file()会在移动成功后自动删除临时上传的文件吗?

只是为了摆脱困惑,我需要做到这一点:

  //成功上传
if( move_uploaded_file($ file ['tmp_name'],$ destination)){
unlink($ file ['tmp_name']);
返回TRUE;
} else {
//上传失败
unlink($ file ['tmp_name']);
返回FALSE;

$ / code>

或者根本不需要?
您不需要手动 unlink()临时文件;在成功上传后,PHP自行清理完毕。这个函数叫做 move _uploaded_file ,而不是 copy _uploaded_file

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?

解决方案

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.

这篇关于move_uploaded_file()会在SUCCESSful Move后自动删除临时上传的文件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-12 22:30