Advertisement
Guest User

php upload script

a guest
Dec 18th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.94 KB | None | 0 0
  1. <?php
  2. $target_dir = "tictacttoe/inventory/";
  3. $target_file = $target_dir . basename($_FILES["fileName"]["name"]);
  4. $uploadOk = 1;
  5. //$imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
  6. // Check if image file is a actual image or fake image
  7. //if(isset($_POST["submit"])) {
  8.     //$check = getimagesize($_FILES["fileName"]["tmp_name"]);
  9.     if ($_FILES["fileName"]["size"] > 500000) {
  10.     print "Sorry, your file is too large.";
  11.     $uploadOk = 0;
  12. }
  13. if (file_exists($target_file)) {
  14.     echo "Sorry, file already exists.";
  15.     $uploadOk = 0;
  16. }
  17. if ($uploadOk == 0) {
  18.  echo "Sorry, your file was not uploaded.";
  19. // if everything is ok, try to upload file
  20. } else {
  21.    
  22.     if (move_uploaded_file($_FILES["fileName"]["name"], $target_file)) {
  23.         echo "The file ". basename( $_FILES["fileName"]["name"]). " has been uploaded.";
  24.     } else {
  25.         echo "Sorry, there was an error uploading your file.";
  26.     }
  27. }
  28. //}
  29. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement