Jump to content

Maz

Members
  • Posts

    1
  • Joined

  • Last visited

Posts posted by Maz

  1. Hi there,

    I was following your tutorial on PHP and found a little mistake in coding of "File Upload". When I ran the code I was seeing the errors on top of the form after page load. I tried and put the next IF's inside the first IF and it did worked. Just wanted to inform you about this code and hope to fix it for others in the future. Thanks for the great website and wish you all the best.

    Cheers.

     

    if(isset($_POST["submit"])) {
      $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
      if($check !== false) {
        echo "File is an image - " . $check["mime"] . ".";
        $uploadOk = 1;
      } else {
        echo "File is not an image.";
        $uploadOk = 0;
      }
    }
    
    // Check if file already exists
    if (file_exists($target_file)) {
      echo "Sorry, file already exists.";
      $uploadOk = 0;
    }

     

×
×
  • Create New...