So I got this simple HTML form
<form action="upload.php" method="post" enctype="multipart/form-data">
  Select image to upload:
  <input type="file" name="fileToUpload" id="fileToUpload">
  <input type="submit" value="Upload Image" name="submit">
</form>This allows me to upload an image and post it to the server where is it handled by the "upload.php" script.
upload.php looks like this
<?php
$target_dir = "uploads/";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
$uploadOk = 1;
$imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
// Check if image file is a actual image or fake image
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;
  }
}
I would like to use Postman to send these post requests manually, but I don't how to make a proper request in postman.
But the PHP script doesn't recognise $_FILES["fileToUpload"]
I hope someone can tell/explain to me how I can use Postman so send a post request that can be handled by this PHP script.
If it's possible to do exactly this but then in JavaScript, I would love to know.
Have a great weekend :)


 
     
    

