PHP file upload code that supports Multifile upload-PHP source code

Source: Internet
Author: User
Tags php file upload
Ec (2); PHP supports uploading multiple files at the same time and automatically organizing their information in an array. To complete this function, you need to use the same Array submit syntax for the file upload fields in the HTML form and the multi-choice box and the check box. & Nbsp; & lt; title & gt; upload multiple files & lt; title & gt; & lt; link & nbsp; rel & quot; stylesheet & quot; & nbsp; ty script ec (2); script

PHP supports uploading multiple files at the same time and automatically organizing their information in the form of arrays. To complete this function, you need to use the same Array submit syntax for the file upload fields in the HTML form and the multi-choice box and the check box.

Upload multiple files



After the preceding form is submitted, the array $ _ FILES ['userfile'], $ _ FILES ['userfile'] ['name'] and $ _ FILES ['userfile'] ['SIZE'] will be initialized ($ HTTP_POST_FILES before PHP 4.1.0). If register_globals is set to on, the global variables related to file upload will also be initialized. All the submitted information will be stored in an array indexed by numbers.

For example, assume the names are/home/test/review.html and/home/test/xwp. when an out file is submitted, the value of $ _ FILES ['userfile'] ['name'] [0] will be review.html, the value of $ _ FILES ['userfile'] ['name'] [1] is xwp. out. Similarly, $ _ FILES ['userfile'] ['SIZE'] [0] will contain the size of the file review.html, and so on.

In addition, $ _ FILES ['userfile'] ['name'] [0] is also set. $ _ FILES ['userfile'] ['tmp _ name'] [0], $ _ FILES ['userfile'] ['SIZE'] [0] and $ _ FILES ['userfile'] ['type'] [0].

PHP File

Upload_array.php
--------------------------------
For ($ I = 0; $ I {
If ($ userfile_name [$ I] <> "") // checks whether the uploaded file is empty.
{
Copy ($ userfile [$ I], $ userfile_name [$ I]);

Echo "file name:", $ userfile_name [$ I],"
";
Echo "file size:", $ userfile_size [$ I],"
";
Echo "file type:", $ userfile_type [$ I];
}
}
?>

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.