ThinkPHP5.0采用全新的架构思想,引入了更多的PHP新特性,优化了核心,减少了依赖,实现了真正的惰性加载,支持composer,并针对API开发做了大量的优化,包括路由、日志、异常、模型、数据库、模板引擎和验证等模块都已经重构,不适合原有3.2项目的升级,请慎重考虑商业项目升级,但绝对是网站建设和API开发首选。但在使用ThinkPHP5.0中存在后台同时上传多个文件后找不到临时文件,那该如何解决呢?
这是修改之前的代码
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="/uploads/".$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="/uploads/".$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="/uploads/".$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="/uploads/".$info->getSaveName(); }else{ $positive_path=""; } if($org_reverse){ $info1=$org_reverse->move(ROOT_PATH . 'uploads'); $reverse_path="/uploads/".$info1->getSaveName(); }else{ $reverse_path=""; } if($org_license){ $info2=$org_license->move(ROOT_PATH . 'uploads'); $license_path="/uploads/".$info2->getSaveName(); }else{ $license_path=""; } }
以上内容就是绵阳动力网站建设为大家带来的关于ThinkPHP5.0后台中同时上传多个文件后找不到临时文件的解决方法的内容。
地址:绵阳市临园路东段78号B座13层
电话:0816-6339181
邮箱:kf@kf51.cn
微信公众号:
Copyright © 绵阳动力网站建设 www.kf51.cn All Rights Reserved 蜀ICP备08100083号