Php multi-File Upload implementation code _ php instance

Source: Internet
Author: User
This article mainly introduces php multi-File Upload implementation code. For more information, see index_uploads.php.

The Code is as follows:





Index_uploads





Uploads. php

The Code is as follows:


Header ("content-type: text/html; charset = UTF-8 ");
Echo"

";
print_r($_FILES);
echo "
";

$ Count = count ($ _ FILES ['file'] ['name']);

For ($ I = 0; $ I <$ count; $ I ++ ){
$ Tmpfile = $ _ FILES ['file'] ['tmp _ name'] [$ I];
$ Filefix = array_pop (explode (".", $ _ FILES ['file'] ['name'] [$ I]);
$ Dstfile = "uploads/files/". time (). "_". mt_rand (). ".". $ filefix;

If (move_uploaded_file ($ tmpfile, $ dstfile )){
Echo "script" alert ('succeed! '); Window. location. href = 'index _ uploads. php'; script ";
} Else {
Echo "script alert ('fail! '); Window. location. href = 'index _ uploads. php'; script ";
}
}

Core: <1> the name attribute of input in the upload homepage is set in this way.

<2> Use A while LOOP to upload multiple files.

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.