skip to Main Content

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
72

Warning: 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


  1. 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.

    Login or Signup to reply.
  2. $newFilePath = "/images/".$complaintId."_".$_FILES['files']['name'][$i];
    

    change this to

    $newFilePath = "images/".$complaintId."_".$_FILES['files']['name'][$i];
    
    Login or Signup to reply.
  3. 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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search