PHP turned out to be ready for such a construction (square brackets are in the “name” parameter for it), it will simply decompose the downloaded files into the elements of the $ _FILES array, unless we use “Opera”.Copy Source | Copy HTML < form enctype ="multipart/form-data" method ="post"> < input type ="file" min ="1" max ="9999" name ="file[]" multiple ="true" /> < input type ="submit" name ="submit" /> </ form >
Copy Source | Copy HTML < form enctype ="multipart/form-data" method ="post"> < input type ="file" min ="1" max ="9999" name ="file[]" multiple ="true" /> < input type ="submit" name ="submit" /> </ form >
Copy Source | Copy HTML < form enctype ="multipart/form-data" method ="post"> < input type ="file" min ="1" max ="9999" name ="file[]" multiple ="true" /> < input type ="submit" name ="submit" /> </ form >
Copy Source | Copy HTML < form enctype ="multipart/form-data" method ="post"> < input type ="file" min ="1" max ="9999" name ="file[]" multiple ="true" /> < input type ="submit" name ="submit" /> </ form >
Copy Source | Copy HTML < form enctype ="multipart/form-data" method ="post"> < input type ="file" min ="1" max ="9999" name ="file[]" multiple ="true" /> < input type ="submit" name ="submit" /> </ form >
I'm not quite sure about the publication of this article in the blog "PHP", perhaps the "HTML" would be more suitable, on the other hand, here is considered a way to use multiple downloads together in PHP.Copy Source | Copy HTML
- if ( isset ( $ _POST [ 'file' ], $ _POST [ 'file' ] [ 0 ])) {
- if ( $ idx = strpos ( $ _POST [ 'file' ] [ 0 ], "\ n" )) {
- $ bound = substr ( $ _POST [ 'file' ] [ 0 ], 2 , $ idx - 2 );
- $ body = "MIME-Version: 1.0 \ nContent-type: multipart / form-data; boundary = {$ bound} \ n \ n" .
- $ _POST [ 'file' ] [ 0 ];
- unset ( $ _POST [ 'file' ] [ 0 ]);
- $ f = & $ _FILES [ 'file' ];
- $ f [ 'name' ] = $ f [ 'type' ] = $ f [ 'tmp_name' ] = $ f [ 'error' ] = $ f [ 'size' ];
- $ msg = mailparse_msg_create ();
- if (mailparse_msg_parse ( $ msg , $ body )) {
- $ i = 0 ;
- foreach (mailparse_msg_get_structure ( $ msg ) as $ st ) {
- $ section = mailparse_msg_get_part ( $ msg , $ st );
- $ data = mailparse_msg_get_part_data ( $ section );
- if ( $ data [ 'content-type' ] == 'multipart / form-data' ) {
- continue ;
- }
- ob_start ();
- if (mailparse_msg_extract_part ( $ section , $ body )) {
- $ tmp = tempnam (sys_get_temp_dir (), 'php' );
- file_put_contents ( $ tmp , ob_get_clean ());
- $ f [ 'name' ] [ $ i ] = $ data [ 'disposition-filename' ];
- $ f [ 'type' ] [ $ i ] = $ data [ 'content-type' ];
- $ f [ 'tmp_name' ] [ $ i ] = $ tmp ;
- $ f [ 'error' ] [ $ i ] = 0 ;
- $ f [ 'size' ] [ $ i ] = filesize ( $ tmp );
- $ i ++;
- } else {
- ob_end_clean ();
- }
- }
- }
- unset ( $ f );
- mailparse_msg_free ( $ msg );
- }
- }
Source: https://habr.com/ru/post/76749/
All Articles