Posted By

smilylion on 09/09/06


Tagged

php upload local


Versions (?)

Who likes this?

20 people have marked this snippet as a favorite

clifton
maxav
blakeb
oli964
skywalker
JimiJay
gizmo
cjurczak
ibomb
Nix
oriolfb
discorax
irishsk
love
Adam42
dinkan
bobbym245
ijasnijas
mecha
lfcortes


upload php from local


 / Published in: PHP
 

  1. <?php
  2. // basic php file upload example
  3. // http://php.snippetdb.com
  4.  
  5. if ($_POST['upload']){ //process uploaded file
  6. $uploadDir = '/domains/path-com/path/www_root/_crop/full-'; //file upload path
  7. $uploadFile = $uploadDir . $_FILES['uploadfile']['name'];
  8. echo "<pre>";
  9. if (move_uploaded_file($_FILES['uploadfile']['tmp_name'], $uploadFile) )
  10. {
  11. echo "File is valid, and was successfully uploaded. ";
  12. echo "Here's some more debugging info:\n";
  13. }
  14. else
  15. {
  16. echo "ERROR! Here's some debugging info:\n";
  17. echo "remember to check valid path, max filesize\n";
  18. echo "$-POST-upload: ".$_POST['upload'];
  19. }
  20. echo "</pre>";
  21.  
  22. } else { //display upload form
  23. ?>
  24. <form enctype="multipart/form-data" action="<?php echo $_SERVER['SCRIPT_NAME']?>" method="post">
  25. <input type="hidden" name="MAX_FILE_SIZE" value="1111024000">
  26. <br>
  27. <input name="uploadfile" type="file">
  28. <br>
  29. <input name= "upload" type="submit" value="Upload File">
  30. </form>
  31. <?php
  32. }
  33. ?>

Report this snippet  

You need to login to post a comment.