For a php beginner's file upload code (1/3) _ PHP Tutorial

Source: Internet
Author: User
About a file upload code for php beginners (13 ). It is very useful to create a file upload form that allows users to upload files from the form. It is very useful to create a file upload form that allows users to upload files from the form. See create a file upload form below
It is very useful to allow users to upload files from forms.

Create a file upload form
It is very useful to allow users to upload files from forms.
See the following html form for uploading files:
The code is as follows:





Pay attention to the following information about this form:

The enctype attribute of a tag specifies the content type to be used when submitting a form. When a form requires binary data, such as file content, use multipart/form-data ".
The type = "file" attribute of the tag specifies that the input should be processed as a file. For example, when previewing in a browser, a browser button is displayed next to the input box.
Note: allowing users to upload files is a huge security risk. Only trusted users are allowed to upload files.
Create Upload script
The "upload_file.php" file contains the code for uploading files:
The code is as follows:

If ($ _ files ["file"] ["error"]> 0)
{
Echo "error:". $ _ files ["file"] ["error"]."
";
}
Else
{
Echo "upload:". $ _ files ["file"] ["name"]."
";
Echo "type:". $ _ files ["file"] ["type"]."
";
Echo "size:". ($ _ files ["file"] ["size"]/1024). "kb
";
Echo "stored in:". $ _ files ["file"] ["tmp_name"];
}
?>

1 2 3

It is very useful to allow users to upload files from forms. It is very useful to create a file upload form that allows users to upload files from the form. Please refer to the following...

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.