Home >Backend Development >PHP Tutorial >PHP file upload example

PHP file upload example

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-25 08:45:24987browse
Processing code:
  1. header('Content-Type: text/html;charset=UTF-8');
  2. //Ready to receive
  3. /*
  4. echo 'File name:'.$_FILES[ 'userfile']['name'];
  5. echo 'File size:'.$_FILES['userfile']['size'];
  6. echo 'Error:'.$_FILES['userfile']['error'] ; */
  7. //print_r($_FILES)
  8. $tmpFile=$_FILES['userfile']['tmp_name'];
  9. if(is_uploaded_file($tmpFile))
  10. {
  11. echo 'Uploading. . . ';
  12. if(!file_exists('uploads'))//If the folder does not exist
  13. {
  14. mkdir('uploads');
  15. }
  16. $moveFile =move_uploaded_file($tmpFile, 'uploads/'.$_FILES ['userfile']['name']);
  17. if($moveFile)
  18. {
  19. echo "Move successfully!";
  20. //echo ' ';
  21. }else
  22. {
  23. echo 'Move failed! ';
  24. }
  25. }else
  26. {
  27. echo "File not found in temporary folder";
  28. }
  29. ?>
Copy code

HMTL code:
  1. Insert title here
  2. Upload file:
Copy code

File upload, PHP


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn