dongpa3109
2016-05-11 11:38
浏览 92
已采纳

我想在上传时重命名文件以避免覆盖[重复]

This question already has an answer here:

I want to rename the file while uploading to avoid overwriting of files, I have following code, Please suggest code to avoid overwriting.

$path = "admin/uploads/resume/";
    if (!file_exists($path))
        mkdir($path, 0, true);
    $img_name = $_FILES['file']['name'];
    $img_tmp_name = $_FILES['file']['tmp_name'];
    $img_path = $img_name;
    move_uploaded_file($img_tmp_name, "admin/uploads/resume/" . $img_path);

    $img_name = $_FILES['file']['name'];
</div>

图片转代码服务由CSDN问答提供 功能建议

此问题已经存在 这里有一个答案:

  • 如何在将上传的文件保存到目录之前重命名? \ r 4 answers

    我想重命名文件 在上传以避免覆盖文件时,我有以下代码,请建议代码以避免覆盖。

      $ path =“admin / uploads / resume /”; 
     if(if  !file_exists($ path))
     mkdir($ path,0,true); 
     $ img_name = $ _FILES ['file'] ['name']; 
     $ img_tmp_name = $ _FILES ['file'] [  'tmp_name']; 
     $ img_path = $ img_name; 
     move_uploaded_file($ img_tmp_name,“admin / uploads / resume /”。$ img_path);  
     
     $ img_name = $ _FILES ['file'] ['name']; 
       
     
  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题