Example of form design for uploading multiple files in PHP, _PHP tutorial

WBOY
Release: 2016-07-13 10:13:53
Original
1115 people have browsed it

Form design example for uploading multiple files in PHP,

Multiple file uploads and single file uploads are processed in the same way. You only need to provide several more input forms of type "file" on the client and specify different "name" attribute values. For example, in the following code, the user can select three local files to upload to the server at the same time. The client form is as follows:

Copy code The code is as follows:


Multiple file upload form



Select file 1:

Select file 2:

Select file 3:





In the above code, the forms of three file types are organized together in the form of arrays. When the above form is taught to the PHP script file mul_upload.php, the global array $_FILES is also used on the server side to store information about all the above files, but $_FILES has been converted from a two-dimensional array to a three-dimensional array, so that multiple Upload file information. In the script file mul_upload.php, use the print_r() function to output the contents of the $_FILES array. The code is as follows:

Copy code The code is as follows:

//Print the contents of the three-dimensional array $_FILES and check the structure of storing uploaded files
print_r($_FILES);
?>

After selecting three local files for submission, the output results are as follows:

Copy code The code is as follows:

Array(
[myfile]=>Array(
                                                                                                   Array                                                                                                                                                                                                                                                                                                                                                                                                                                                     Since                                                                                                                                                                                                          [2]=>NOTEPAD.EXE) ---$_FILES["myfile"]["name"][2]The name of the third uploaded file
[Type] = & GT; Array (--- $ _ Files ["Myfile"] ["Type"] Storage of the type of all uploaded files
                                                                                                                                                                                                                                 Since                                                                                                                                                                                                                                   Since                                                                                                                                                                                                                                                                                through          [tmp_name]=>Array(
                       [0]=>C:WINDOWSTempphpAF.tmp
                                                [1]=>C:WINDOWSTempphpB0.tmp
                                       [2]=>C:WINDOWSTempphpB1.tmp)
         [error]=>Array(
                                                  [0]=>0
                                                     [1]=>0
                                                                                                                                 [2]=>0)
         [size]=>Array(
                                      [0]=>64
                                         [1]=>1350
[2]=>66560))
)



By outputting the value of the $_FILES array, you can see that the upload of multiple files is the same as the upload of a single file, except that the structure of the $_FILES array is slightly different. This way a larger number of file uploads can be supported.


http://www.bkjia.com/PHPjc/914041.html

www.bkjia.com

true

TechArticleForm design example for uploading multiple files in PHP. Multiple file uploads and single file uploads are processed in the same way. Yes, you just need to provide a few more inputs of type "file" on the client...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!