Advertisement
Valleri

Upload File PHP

Aug 20th, 2014
504
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.78 KB | None | 0 0
  1. <?php
  2. if(isset($_FILES['file'])) {
  3.     $name = $_FILES['file']['name'];
  4.     $size = $_FILES['file']['size'];
  5.     $type = $_FILES['file']['type'];
  6.     $tmp_name = $_FILES['file']['tmp_name'];
  7.  
  8.     $error = $_FILES['file']['error'];
  9.  
  10.     if(isset($name)) {
  11.         if(!empty($name)) {
  12.             $location = "uploads/";
  13.             if(move_uploaded_file($tmp_name, $location . $name)) {
  14.                 echo "uploaded";
  15.             }
  16.         } else {
  17.             echo "Please choose a file";
  18.         }
  19.     }
  20. }
  21. ?>
  22. <html>
  23. <body>
  24. <form action="upload_file.php" method="post"
  25.       enctype="multipart/form-data">
  26.     <label for="file">Filename:</label>
  27.     <input type="file" name="file"><br>
  28.     <input type="submit" name="submitBtn" value="Upload">
  29. </form>
  30.  
  31. </body>
  32. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement