這是修改之前的代碼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=""; } }
本人是小白,在網上查找到資料說php上傳檔案後較短時間會删除臨時檔案,也就是$_FILES[‘file"][‘tmp_name"]這個值,修改代碼之後沒有報錯了,成功将臨時檔案轉移了出來
總結
以上所述是小編給大家介紹的ThinkPHP5.0多個檔案上傳後找不到臨時檔案的修改方法,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回複大家的。在此也非常感謝大家對網頁設計網站的支援!