In fact, multiple file uploads are similar to single file uploads. The principles are the same. First of all, it is still the index.html upload form, but the file in the previous file upload form is changed to file[ ]
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
|
Use $_FILES to print in upload.php and see
1 2 3 |
|
Get the followingMultidimensional array
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
|
Upload as a single file principle, first think about what we need to get?
Obviously we need to get an array of file information. The array contains name, type, tmp_name, error, size. At this time, what we get is a multi-dimensional array. Although the corresponding key values exist, but It is multi-dimensional.
We only need to split it. For example, for the three files above, we only need to split it into the corresponding three file information arrays.
The structure of the split array
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
|
The following is the code for splitting and reorganizing the array
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
The rest is simple. Repeat the steps of uploading a single file and traverse the process. The array will do.
The code is as follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
|
The above is the detailed content of How to implement multiple file upload in php. For more information, please follow other related articles on the PHP Chinese website!