Can't upload any jpg or png files

I can get a couple of files to be uploaded but for some reason, my other files can’t be moved. I have the following form where the user can submit a medical review but only the first medical review can upload their pictures, I am just not sure why it is not moving all of my other pictures:

 for($x=0; $x <count($_FILES['file']['name']); $x++) {
      
  

  $file = $_FILES['file'];
  $fileName = $_FILES['file']['name'][$x];
  $fileTmpName= $_FILES['file']['tmp_name'][$x];
  $fileSize = $_FILES['file']['size'][$x];
  $fileError = $_FILES['file']['error'][$x];
  $fileType = $_FILES['file']['type'][$x];
 
  $fileExt = explode('.', $fileName);
  $fileActualExt = strtolower(end($fileExt));
  

  $allowed = array('jpg', 'jpeg', 'png', 'pdf');

  if (!in_array($fileActualExt, $allowed)) {
      echo "<meta http-equiv='refresh' content='0;url=index.php?upload_form=error'>";
      exit();
  } else {
      if ($fileError === 1) {
          echo "<meta http-equiv='refresh' content='0;url=index.php?upload_form=errorwithform'>";
        exit();
      } else {
         if ($fileSize > 5000000000) {
            echo "<meta http-equiv='refresh' content='0;url=index.php?upload_form=filesizeerror'>";
        exit();
         } else {
                  $id = $_SESSION['u_id'];
                  $fileNameNew = "profile".$id.".".$fileActualExt;
                  $fileDestination = 'uploads/'.$fileNameNew;
                   move_uploaded_file($fileTmpName, $fileDestination);
             
            
            
            $sql2 = "INSERT INTO pictures (name, pictures) VALUES (?,?);";
            
            $stmt = mysqli_stmt_init($conn);
                        if(!mysqli_stmt_prepare($stmt, $sql2)) {
                           echo "SQL error";
                        } else {
                          mysqli_stmt_bind_param($stmt, "ss", $clinic_name, $fileDestination);
                          mysqli_stmt_execute($stmt);
                        }              
            
         echo "<meta http-equiv='refresh' content='0;url=index.php?medical_review_process=success'>";

Do I also need an [$x] in my first line and on my html form, should it be as follows:

Upload pictures here to support information:




or should it be multiple=“multiple” or multiple=“”

Whenever I upload multiple files, sometimes it does get confused between given them different names but it seems to work ok when I upload them one at a time…

There are some confusing information about the use of the tag multiple…

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.