PHP File Upload

Source: Internet
Author: User

The receipt parameters of the form can be obtained by using an array of $_get or $_post, but the file field, although shown to be post, must use the $_files.

Differences between 1.$_get ($HTTP _get_vars) and $_post ($HTTP _post_vars)

2.$_files uploading and receiving files

2.1 Issues that you may encounter when uploading files

What are the keys of 2.2$_files

Name, type, size, tmp_name

2.3is_uploaded_file () method

2.4move_uploaded_file () method

------------------------------------------------------

Issues that you may encounter when uploading files

Note: The resulting file is too large to handle

Workaround 1: Remove the hard limit and change the upload_max_filesize option in php.ini to 2 megabytes or more for the length of the uploaded file

Workaround 2: Submit a parameter named Upload_max_filesize before the file field is submitted, then PHP will use that value as a soft limit for file size.

2.2 Key value of $_files

1.name the file name provided by the browser.

2.type the MIME type of the uploaded file.

3.size the size (in bytes) of the uploaded file.

4.tmp_name a temporary file name for uploading files in the server.

-----------------------------------------------------------

Form processing

Is_uploaded_file () method

Format:

if (Is_uploaded_file ($_files[' toprocess ' [' tmp_name ']))

{

Upload successful

}

Detects if a file has been successfully uploaded

Is_uploaded_file ($_files[' toprocess ' [' Tmp_name '], "path/to/put/file/$file")

/Move the uploaded file from the Temp folder to the specified directory, and when this method is called, the file is automatically detected for upload.

PHP File Upload

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.