donglilian0061 2019-01-13 12:53
浏览 60

删除文件,取消链接资源温度不可用

I Am trying to delete a file that is being replaced with a new file upload, However i am using unlink an i get the error RESOURCE TEMP UNAVAILABLE

tried to wait for a few seconds before trying to unlink. tried unsetting the temp file

 if (isset($_POST['oldimagesrc'])){ $oldimagesrc=$_POST['oldimagesrc'];
 $oldimagesrc = filter_var($oldimagesrc, FILTER_SANITIZE_STRING);
 $oldimagesrc = strip_tags($oldimagesrc);

 $dir="../imageupload/images/";

 $oldimagelocation = $dir.$oldimagesrc;

 $tempfile=$_FILES["image"]["tmp_name"];


 if (move_uploaded_file($tempfile,$newimagelocation)) {

  if (unlink($oldimagelocation)) {                                                                                  

   die($savetoDB);

     exit();

 }

 else 

 {

  die("Could Not Delete File");

  exit();

}


 }

I would hope there is some work around like a way to clear the cached file allthough i have tried to unset the temp file..

P.S

Sometimes it works while other times i get the error...

  • 写回答

1条回答 默认 最新

  • duanmie9682 2019-01-13 17:19
    关注
    1. Try to rename the file after upload and save.
    2. Store renamed file path or name into the database.
    3. Get OLD Filename & store at local variable.
    4. Upload new file > rename > save > delete old file (using old name).
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 matlab有关常微分方程的问题求解决
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考