如何解决ThinkPHP5.0批量上传文件后临时文件丢失的问题?

更新于
2026-09-23 07:13:07
1阅读来源:SEO资讯
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计373个文字,预计阅读时间需要2分钟。

如何解决ThinkPHP5.0批量上传文件后临时文件丢失的问题?

这是修改前的代码段:

phpif (!empty($FILES)) { if (!empty($FILES['org_positive'])) { $org_positive=request() - file('org_positive'); if ($org_positive) { $info=$org_positive->move(ROOT_PATH . 'uploads'); $positive_path=/uploads/ . $info->get(); } }}

这是修改之前的代码

if(!empty($_FILES)){ if(!empty($_FILES['org_positive'])){ $org_positive = request()->file('org_positive'); if($org_positive){ $info = $org_positive->move(ROOT_PATH . 'uploads'); $positive_path="img.558idc.com/uploadfile/".$info->getSaveName(); }else{ $positive_path=""; } } if(!empty($_FILES['org_reverse'])){ $org_reverse = request()->file('org_reverse'); if($org_reverse){ $info1=$org_reverse->move(ROOT_PATH . 'uploads'); $reverse_path="img.558idc.com/uploadfile/".$info1->getSaveName(); }else{ $reverse_path=""; } } if(!empty($_FILES['org_license'])){ $org_license = request()->file('org_license'); if($org_license){ $info2=$org_license->move(ROOT_PATH . 'uploads'); $license_path="img.558idc.com/uploadfile/".$info2->getSaveName(); }else{ $license_path=""; } } }

在处理$_FILES第二个元素的时候出现了以下错误

这是改良之后的代码

if(!empty($_FILES)){ if(!empty($_FILES['org_positive'])){ $org_positive = request()->file('org_positive'); } if(!empty($_FILES['org_reverse'])){ $org_reverse = request()->file('org_reverse'); } if(!empty($_FILES['org_license'])){ $org_license = request()->file('org_license'); } if($org_positive){ $info = $org_positive->move(ROOT_PATH . 'uploads'); $positive_path="img.558idc.com/uploadfile/".$info->getSaveName(); }else{ $positive_path=""; } if($org_reverse){ $info1=$org_reverse->move(ROOT_PATH . 'uploads'); $reverse_path="img.558idc.com/uploadfile/".$info1->getSaveName(); }else{ $reverse_path=""; } if($org_license){ $info2=$org_license->move(ROOT_PATH . 'uploads'); $license_path="img.558idc.com/uploadfile/".$info2->getSaveName(); }else{ $license_path=""; } }

本人是小白,在网上查找到资料说php上传文件后较短时间会删除临时文件,也就是$_FILES[‘file'][‘tmp_name']这个值,修改代码之后没有报错了,成功将临时文件转移了出来

总结

如何解决ThinkPHP5.0批量上传文件后临时文件丢失的问题?

以上所述是小编给大家介绍的ThinkPHP5.0多个文件上传后找不到临时文件的修改方法,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对易盾网络网站的支持!

本文共计373个文字,预计阅读时间需要2分钟。

如何解决ThinkPHP5.0批量上传文件后临时文件丢失的问题?

这是修改前的代码段:

phpif (!empty($FILES)) { if (!empty($FILES['org_positive'])) { $org_positive=request() - file('org_positive'); if ($org_positive) { $info=$org_positive->move(ROOT_PATH . 'uploads'); $positive_path=/uploads/ . $info->get(); } }}

这是修改之前的代码

if(!empty($_FILES)){ if(!empty($_FILES['org_positive'])){ $org_positive = request()->file('org_positive'); if($org_positive){ $info = $org_positive->move(ROOT_PATH . 'uploads'); $positive_path="img.558idc.com/uploadfile/".$info->getSaveName(); }else{ $positive_path=""; } } if(!empty($_FILES['org_reverse'])){ $org_reverse = request()->file('org_reverse'); if($org_reverse){ $info1=$org_reverse->move(ROOT_PATH . 'uploads'); $reverse_path="img.558idc.com/uploadfile/".$info1->getSaveName(); }else{ $reverse_path=""; } } if(!empty($_FILES['org_license'])){ $org_license = request()->file('org_license'); if($org_license){ $info2=$org_license->move(ROOT_PATH . 'uploads'); $license_path="img.558idc.com/uploadfile/".$info2->getSaveName(); }else{ $license_path=""; } } }

在处理$_FILES第二个元素的时候出现了以下错误

这是改良之后的代码

if(!empty($_FILES)){ if(!empty($_FILES['org_positive'])){ $org_positive = request()->file('org_positive'); } if(!empty($_FILES['org_reverse'])){ $org_reverse = request()->file('org_reverse'); } if(!empty($_FILES['org_license'])){ $org_license = request()->file('org_license'); } if($org_positive){ $info = $org_positive->move(ROOT_PATH . 'uploads'); $positive_path="img.558idc.com/uploadfile/".$info->getSaveName(); }else{ $positive_path=""; } if($org_reverse){ $info1=$org_reverse->move(ROOT_PATH . 'uploads'); $reverse_path="img.558idc.com/uploadfile/".$info1->getSaveName(); }else{ $reverse_path=""; } if($org_license){ $info2=$org_license->move(ROOT_PATH . 'uploads'); $license_path="img.558idc.com/uploadfile/".$info2->getSaveName(); }else{ $license_path=""; } }

本人是小白,在网上查找到资料说php上传文件后较短时间会删除临时文件,也就是$_FILES[‘file'][‘tmp_name']这个值,修改代码之后没有报错了,成功将临时文件转移了出来

总结

如何解决ThinkPHP5.0批量上传文件后临时文件丢失的问题?

以上所述是小编给大家介绍的ThinkPHP5.0多个文件上传后找不到临时文件的修改方法,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对易盾网络网站的支持!