PHP multi-file Upload analysis _ PHP Tutorial

Source: Internet
Author: User
PHP multi-file Upload analysis. PHP multi-file Upload I personally understand that multi-file upload is a basic application in PHP. I would like to give you a detailed introduction here. I have a limited level. please give more comments. I personally understand that multifile upload is a basic application in PHP. I would like to introduce the relevant knowledge to you here. I have a limited level. I would like to provide more comments. Everyone makes progress together.
Add [] to the name of the input tag FILE type of the html file to create an array in the html file. for example, the name is pictures, the multi-file reference name is pictures [], and the instance is as follows:
// Example in the manual.
The methods for creating arrays using HTML files are described as follows:

To make yourPHP receiving File:
print_r($_FILES);
?>
Save it as UPLOAD. PHP and run the above HTML to select a file to UPLOAD. for example, if the file name is Thumbs. db, click View and source code in IE browser ". Shown as follows:
Array
(
[Pictures] => Array
(
[Name] => Thumbs. db // original file name
[Type] => application/octet-stream // file type
[Tmp_name] => D: EasyPHP \ tmpphp64.tmp // temporary storage directory and file name
[Error] => 0 // error code 0 indicates that the upload is successful.
[Size] => 23040 // file size
)
) According to this information, combined with the usage of the above $ _ FILES, you should be able to understand more deeply.


Next let's take a look at multifile Upload. The three file names are FILE1.TXT, FILE2.TXT, and FILE3.TXT respectively, and then use PRINT_R output to view their structure:

HTML file code:
PHP receiving file code:
print_r($_FILES);
?>
View source files:

Array
(
[Pictures] => Array
(
[Name] => Array
(
[0] => file1.txt
[1] => file2.txt
[2] => file3.txt
)
[Type] => Array
(
[0] => application/octet-stream
[1] => application/octet-stream
[2] => application/octet-stream
)
[Tmp_name] => Array
(
[0] => D: EasyPHP \ tmpphp47.tmp
[1] => D: EasyPHP \ tmpphp48.tmp
[2] => D: EasyPHP \ tmpphp49.tmp
)
[Error] => Array
(
[0] => 0
[1] => 0
[2] => 0
)
[Size] => Array
(
[0] = & gt; 94289
[1] => 65536.
[2] => 102400.
)
)
)
If the FILES named/file1.txt and/file2.txt are submitted, the value of $ _ FILES ['pictures'] ['name'] [0] will be file1.txt, the value of $ _ FILES ['pictures'] ['name'] [1] is file2.txt. When 'file2.txt '] ['size'] [0] will contain the size of the file file1.txt, and so on.

Upload multiple files is a basic application in PHP. I would like to introduce the relevant knowledge here. I have a limited level. please provide more comments. Everybody one...

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.