SHARE
TWEET

Untitled

a guest Apr 24th, 2019 85 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. if ($_FILES["imgFile"]["error"] > 0)
  4. {
  5.     // Something happened that prevented the file from uploading...
  6.     print ("<p>File Upload Error: " . $_FILES["imgFile"]["error"] . "</p>");
  7. }
  8. elseif(
  9.     ($_FILES["imgFile"]["type"] == "image/gif") ||
  10.     ($_FILES["imgFile"]["type"] == "image/jpeg") ||
  11.     ($_FILES["imgFile"]["type"] == "image/jpg") ||
  12.     ($_FILES["imgFile"]["type"] == "image/png") &&
  13.     ($_FILES["imgFile"]["size"] < 1000000)
  14. )
  15. {
  16.     // The file uploaded without any issues, so get...
  17.     // - file name
  18.     $filename = $_FILES["imgFile"]["name"];
  19.     // - tmp name
  20.     $tmpname = $_FILES["imgFile"] ["tmp_name"];
  21.     // - path
  22.     $path = "uploads\\";
  23.     // ...set the destination...
  24.     $imgURL = $destpath  . $filename;
  25.     // ...and try to copy the file...
  26.     if(file_exists($imgURL))
  27.     {
  28.         // - The file already exists... That's an error!
  29.         print("<p>File Upload Error: " . $filename . " already exists.</p>");  
  30.     }
  31.     else
  32.     {
  33.         // - Try to move the uploaded file to the destination
  34.         if(move_uploaded_file($tmpname, $imgURL))
  35.         {
  36.             // - It worked, so let the user know it worked
  37.             print("<p>File "  .  $filename  .  " uploaded successfully.</p>");
  38.         else
  39.         {
  40.             // - An error occurred, so let the user know:
  41.             print("<p>File Upload Error: " .  "File cannot be moved.</p>");
  42.         }
  43. }
  44.        
  45. else
  46. {
  47.     // - Some other error occurred, let the user know...
  48.     print("<p>File upload Error:Invalid File </p>");
  49. }
  50.  
  51. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top