Warning: move_uploaded_file(/images/24_silver_2_1.jpg): failed to open stream: No such file or directory in C:\\Inetpub\\vhosts\\leojungen.com\\httpdocs\\launch-complaint.php on line 72
Warning: move_uploaded_file(): Unable to move 'C:\\Windows\\Temp\\php19A2.tmp' to '/images/24_silver_2_1.jpg' in C:\\Inetpub\\vhosts\\leojungen.com\\httpdocs\\launch-complaint.php on line 72
function uploadMultipleFiles($complaintId){
global $_pdo;$path = '';
// Count # of uploaded files in array
$total = count($_FILES['files']['name']);
// Loop through each file
for($i=0; $i<$total; $i++) {
//Get the temp file path
$tmpFilePath = $_FILES['files']['tmp_name'][$i];
//Make sure we have a filepath
if ($tmpFilePath != ""){
//Setup our new file path
$newFilePath = "/images/".$complaintId."_".$_FILES['files']['name'][$i];
//Upload the file into the temp dir
//echo "path: "; print_r($_SERVER);exit;
move_uploaded_file($tmpFilePath,$newFilePath);
}
$path .= $complaintId."_".$_FILES['files']['name'][$i]."^";
}
}
In my local environment everything is working file, but when i deployed it on live, it is not working.
This is because either the directory /images
is not present on the server or write permission
on that directory is missing. Check and fix this and try again.
$newFilePath = "/images/".$complaintId."_".$_FILES['files']['name'][$i];
更改为
$newFilePath = "images/".$complaintId."_".$_FILES['files']['name'][$i];
instead of : $newFilePath = "/images/".$complaintId."_".$_FILES['files']['name'][$i];
please try the below :
$newFilePath = "./images".$complaintId."_".$_FILES['files']['name'][$i];
the Period in ./images means root/images....if there are other in between root and images..include it
I know its very old question but I am posting this answer so that if any newcoder like me comes...he get the solution that worked for me
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.