turt2live

PHP Upload

Dec 27th, 2011
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.72 KB | None | 0 0
  1. <?php
  2. if($_POST['submit']){
  3.     $target_path = "files/";
  4.  
  5.     $target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
  6.  
  7.     if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
  8.         echo "The file ".  basename( $_FILES['uploadedfile']['name']).
  9.         " has been uploaded. <a href='files'>File Listing</a>";
  10.     } else{
  11.         echo "There was an error uploading the file, please try again!";
  12.     }
  13.     echo "<hr>";
  14. }
  15. ?>
  16.  
  17. <form enctype="multipart/form-data" action="<?php echo __FILE__; ?>" method="POST">
  18. <input type="hidden" name="MAX_FILE_SIZE" value="100000" />
  19. Choose a file to upload: <input name="uploadedfile" type="file" /><br />
  20. <input type="submit" value="Upload File" name='submit'/>
  21. </form>
Advertisement
Add Comment
Please, Sign In to add comment