Client-side image processing with HTML


For client-side processing and uploading, you can try to run the following code −

<?php
   if (isset($_FILES["image"])) {
      $ iSize = getimagesize($_FILES["image"]["tmp_name"]);

      if ($iSize!== false) {
         $myFile = "/tmp/" . basename($_FILES["image"]["name"]);

         if (move_uploaded_file($_FILES["image"]["tmp_name"], $myFile)) {
            echo "File stored at " . $myFile;
         } else {
            echo "Image storage failed!";
         }
      } else {
         echo "This isn’t an image!";
      }
   } else {
      echo "Image not available to upload!";
   }
?>

Samual Sam
Samual Sam

Learning faster. Every day.

Updated on: 25-Jun-2020

267 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements