Five-minute solution php upload file code demo _php Tutorial

Source: Internet
Author: User
When learning PHP, you may encounter PHP upload file problems, here will introduce the detailed PHP upload file code to solve this problem, here to take out and share with you. PHP's syntax is very simple, it is the simplicity of it, making it the current Internet first programming language.

You do not need to have a lot of knowledge to get started, such as: You learn C language, you must have a good understanding of how each variable is defined, how the pointer is manipulated, how memory is created and destroyed, and so on. Another example: You learn the Java language, you must have an object-oriented (OO) Foundation, it must be clear when you need to encapsulate, when to inherit, when the need for polymorphism, to do the project, how to understand the point of SSH. Most users of PHP may not have so much to pay attention to, some people like process-oriented, you write code in a process-oriented way, some people like object-oriented, then you write code in an object-oriented way. PHP is due to the Internet, is currently the Internet Web2.0 first programming language. Meet user needs is always the first, maintainability can be placed in the second place. We often say that Web applications are always beta, and the plans are far from changing.

 
 
  1. >
  2. < Htmlxmlns Htmlxmlns = "http://www.w3.org/1999/xhtml" >
  3. <head>
  4. < metahttp-equiv metahttp-equiv = "Content-type" content = "text/html; CharSet = gb2312 " />
  5. < title > Untitled Document title>
  6. head>
  7. <body>
  8. < Formenctype Formenctype = "Multipart/form-data" Action = "upload.php" Method = "POST" >
  9. < InputType InputType = "hidden" name = "Max_file_size" value = 300000 >
  10. < InputName InputName = "UserFile" type = "File" >
  11. < InputType InputType = "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 succeeded!");
  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 upload file code, we hope to be helpful.


http://www.bkjia.com/PHPjc/446553.html www.bkjia.com true http://www.bkjia.com/PHPjc/446553.html techarticle When learning PHP, you may encounter PHP upload file problems, here will introduce the detailed PHP upload file code to solve this problem, here to take out and share with you. PHP's syntax is very ...

  • Related Article

    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.