Php implements multi-file upload program code. Php file upload is not much different from multifile Upload. multifile Upload only changes the form name to an array, with foreach traversal, you can upload multiple files. php file uploading is not much different from uploading multiple files. multifile Upload only changes the form name to an array, you can use foreach traversal to upload multiple files. for dynamic multi-file upload, you only need to add a dynamic multi-file upload box in js, in the same way, when processing in php, just traverse the array.
The simplest example is as follows:
| The code is as follows: |
|
Foreach ($ _ FILES ["pictures"] ["error"] as $ key => $ error ){ If ($ error = UPLOAD_ERR_ OK ){ $ Tmp_name = $ _ FILES ["pictures"] ["tmp_name"] [$ key]; $ Name = $ _ FILES ["pictures"] ["name"] [$ key]; Move_uploaded_file ($ tmp_name, "data/$ name "); } } ?> |
The following is an example of other friends.
Example 1
| The code is as follows: |
|
// Filename: multi_upload.php If ($ ifupload) { $ Path = AddSlashes (dirname ($ PATH_TRANSLATED). "upload "; For ($ I = 1; $ I <= 8; $ I ++) { $ Files = "afile". $ I; If ($ {$ files }! = "None ") { If (copy ($ {$ files}, $ path. $ {$ files. "_ name "})) { } } } Print"You have uploaded files successfully "; Print "Return "; Exit; } ?>
Upload multiple files
|