php - i am unable to upload multiple images in database

992

i want to upload multiple images using single input. i have two database table say user table and images table. i want to upload all images in image table and data like user name ,email etc in user table. my problem is that i have successfully upload all data in user table but unable to upload images in image table. i am getting any error message but still images is not been upload in image table.. please help me out.. i am getting stuck on it for three days..

this is my view

<input type="file" class="input" name="Image[]" multiple accept="image/*" />

this is my php code.. i am inserting user information in assgnmentUser table and images in UploadImagesLog can any body please tell me whats the issue in uploading multiple images...

$sql="INSERT INTO eOPS.assgnmentUser (
            FirstName,
            LastName,
            Email,
            PostCode,
            CreatedBY,
            CreatedDate,
            IsActive

          )VALUES
              ('".$FirstName."',
              '". $LastName."',
              '". $EmailAddress."',
              '". $postCode."',
              '". $CreatedBy."',
              '". $CreatedDate."',
              0)    
              ";

        mysqli_query($connection, $sql);
        // Count total files
        $countfiles = count($_FILES['Image']['name']);
        $lastUserId = mysqli_insert_id($connection);
        // Looping all files
      for($i=0; $i<$countfiles; $i++){

          $filename = $_FILES['Image']['name'][$i];

          $tmpname = file_get_contents($_FILES['Image']['tmp_name'][$i]);

          $dir = "/var/www/orangehrm/admin/images";

          $dirfilename = $dir ."/". $filename;

          // Upload file
          if(move_uploaded_file($_FILES['Image']['tmp_name'][$i] , $dirfilename)){
            $sql="INSERT INTO eOPS.UploadImagesLog (
              User_ID,
              ImageName,
              ImagePath,
              CreatedBY,
              CreatedDate,

            )VALUES
                ('".$lastUserId."',
                '". $filename."',
                '". $dir."',
                '". $CreatedBy."',
                '". $CreatedDate."'
                )   
                ";
              //  print_r($sql); exit(); 
                 mysqli_query($connection, $sql);

                }


            }

        header("Location: ".$GLOBALS["BrowserURLStart"]."/admin/eOps/AssignmentTask-13/ListingFormImg.php");

People are also looking for solutions to the problem: php - App Proxy downloading file instead of rendering liquid

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.