Advertisement
brnzi

Untitled

Jun 7th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.66 KB | None | 0 0
  1. $target_dir = "uploads/";
  2. $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
  3. $uploadOk = 1;
  4. $imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
  5. if (file_exists($target_file)) {
  6.     echo "Sorry, file already exists.";
  7.     $uploadOk = 0;
  8. }
  9. if ($uploadOk == 0) {
  10.     echo "Sorry, your file was not uploaded.";
  11. // if everything is ok, try to upload file
  12. } else {
  13.     if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
  14.         echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded.";
  15.     } else {
  16.         echo "Sorry, there was an error uploading your file.";
  17.     }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement