Reputation: 1327
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.
Upvotes: 0
Views: 1957
Reputation: 1
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
Upvotes: 0
Reputation: 35
$newFilePath = "/images/".$complaintId."_".$_FILES['files']['name'][$i];
change this to
$newFilePath = "images/".$complaintId."_".$_FILES['files']['name'][$i];
Upvotes: 1
Reputation: 26258
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.
Upvotes: 2