Multifile Upload using PHP

Source: Internet
Author: User
PHP implements multi-file upload, and requires an example of PHP to implement multi-file upload. paste the code directly. thank you.


Reply to discussion (solution)

No one else ....

Baidu swfupload. download an instance and study it.
Uploading multiple files is not just a few pieces of code.

Will a single file be uploaded? If yes, multiple files are the same. Only form controls are named as arrays. php only processes arrays.

$ _ FILES ["file"] how to receive array FILES
Foreach ($ _ FILES ["file"] as $ item)
{
$ S = $ s. ",". $ item;
}
Only one file can be received

What is your html code?

If ($ _ FILES ['file'] ['size']> 0 ){
If ($ _ FILES ["file"] ["error"]> 0 ){
$ Msg = "Attachment Upload error:". $ _ FILES ["file"] ["error"];
} Else {
// If (file_exists ("upload/". $ _ FILES ["file"] ["name"]) {
// Echo $ msg = $ _ FILES ["file"] ["name"]. "The attachment already exists! ";
//} Else {
$ Yc =$ _ POST ['yc'];
$ Yt = $ _ POST ['yt'];
$ Type = $ _ POST ['type'];
$ NewFileName = str_replace (".", "_". time (). ".", $ _ FILES ["file"] ["name"]);
$ Path = "upload/". $ newFileName;
Move_uploaded_file ($ _ FILES ["file"] ["tmp_name"], $ path );

$ SQL = "insert into A004 (c02, c03, c04, c05, c06, c07, c08, c09, c10) values ('". $ id. "','". $ newFileName. "','". $ path. "','". $ yc [0]. "','". $ yt [0]. "','". $ type [0]. "', '0 ','". $ _ SESSION ['login _ id']. "','". get_time (). "')";
$ Msg = $ DB-> Update ($ SQL, "[10016] failed to submit data. please try again later or contact the technician! ");

//}
}
}








JQuery dynamically adds the input type = file upload field

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.