Five-minute PHP file upload code demo _ PHP Tutorial

Source: Internet
Author: User
Tags php file upload
Five minutes to solve the PHP file upload code demonstration. 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. When you are very familiar with php syntax, you may encounter PHP file upload problems. here we will introduce the detailed PHP file upload code to solve this problem. I will share it with you here. 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. <Body>
  8. <FormenctypeFormenctype= "Multipart/form-data"Action= "Upload. php"Method="Post">
  9. <InputtypeInputtype= "Hidden"Name= "Max_file_size"Value=300000>
  10. <InputnameInputname= "Userfile"Type= "File">
  11. <InputtypeInputtype="Submit">
  12. Form>
  13. Body>
  14. Html>
  15. // Upload. php
  16. Php
  17. $Uploaddir="C :\";
  18. $Uploadfile= $ Uploaddir. $ _ FILES ['userfile'] ['name'];
  19. Print"<Pre>";
  20. If (move_uploaded_file ($ _ FILES ['userfile'] ['tmp _ name'], $ uploadfile ))
  21. {
  22. Print ("Upload successful! ");
  23. Print_r ($ _ FILES );
  24. }
  25. Else
  26. {
  27. Print ("Upload failed! ");
  28. Print_r ($ _ FILES );
  29. }
  30. Print" Pre>";
  31. ?>

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


Bytes. Php syntax is very...

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.