Warning: move_uploaded_file(/images/24_silver_2_1.jpg): failed to open
stream: No such file or directory in
C:Inetpubvhostsleojungen.comhttpdocslaunch-complaint.php on line
72Warning: move_uploaded_file(): Unable to move
‘C:WindowsTempphp19A2.tmp’ to ‘/images/24_silver_2_1.jpg’ in
C:Inetpubvhostsleojungen.comhttpdocslaunch-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.
3
Answers
This is because either the directory
/images
is not present on the server orwrite permission
on that directory is missing. Check and fix this and try again.change this to
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