5-minute PHP file upload code demonstration

Source: Internet
Author: User

When learning PHP, you may encounter PHP File Upload problems. Here we will introduce the detailed PHP file upload code to solve this problem. Here we will share it with you. The syntax of php is very simple. It is its simplicity that makes it the first programming language on the Internet.

You don't need to have a lot of knowledge to get started. For example, if you are learning C language, you must have a good understanding of how variables are defined, how pointers are operated, and how memory is created and destroyed. For example, if you want to learn the Java language, you must have the foundation of object-oriented (OO). Then you must know when encapsulation is required, when inheritance is required, and when polymorphism is required, to do a project, you must understand SSH. Most PHP users may not be so specific at all. Some users prefer process-oriented, so you can write code in process-oriented mode. Some users prefer object-oriented, then you can write code in an object-oriented way. The emergence of Php is due to the Internet, and is currently the first programming language of Internet Web. Satisfying user needs is always the first, and maintainability can be placed in the second place. We usually say that Web applications are always beta, and the plan is far from changing rapidly.

 
 
  1. > 
  2. <HtmlxmlnsHtmlxmlns=Http://www.w3.org/1999/xhtml"> 
  3. <Head> 
  4. <Metahttp-equivMetahttp-equiv= "Content-Type"Content= "Text/html;Charset=Gb2312"/> 
  5. <Title>Untitled document Title> 
  6. Head> 
  7.  
  8. <Body> 
  9. <FormenctypeFormenctype= "Multipart/form-data"Action= "Upload. php"Method="Post"> 
  10. <InputtypeInputtype= "Hidden"Name= "Max_file_size"Value=300000> 
  11. <InputnameInputname= "Userfile"Type= "File"> 
  12. <InputtypeInputtype="Submit"> 
  13. Form> 
  14. Body> 
  15. Html> 
  16.  
  17. // Upload. php
  18. Php 
  19. $Uploaddir="C :\";
  20. $Uploadfile= $ Uploaddir. $ _ FILES ['userfile'] ['name'];
  21. Print"<Pre>";
  22. If (move_uploaded_file ($ _ FILES ['userfile'] ['tmp _ name'], $ uploadfile ))
  23. {
  24. Print ("Upload successful! ");
  25. Print_r ($ _ FILES );
  26. }
  27. Else
  28. {
  29. Print ("Upload Failed! ");
  30. Print_r ($ _ FILES );
  31. }
  32. Print" Pre>";
  33. ?> 

The above is the detailed PHP file upload code, and I hope to help you.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.