HTTP协议一次上传多个文件的方法

如何通过HTTP协议一次上传多个文件呢?在这里有两个思路,是同一个方法的两种实现。具体程序还需自己去设计

1. 在form中设置多个文件输入框,用数组命名他们的名字,如下:

1 < form action="" method="post" >
2 
3 < input name="usefile[]" type="file" >
4 
5 < input name="usefile[]" type="file" >
6 
7 < input name="usefile[]" type="file" >
8 
9 < /form >

这样,在服务器端做以下测试:

 1 echo " < pre > "; print_r($_FILES); echo " < /pre > "; 

2. 在form中设置多个文件输入框,但名字不同,如下:

1 < form action="" method="post" >
2 
3 < input name="usefile_a" type="file" >
4 
5 < input name="usefile_b" type="file" >
6 
7 < input name="usefile_c" type="file" >
8 
9 < /form >

在服务器端做同样测试:

 1 echo " < pre > "; print_r($_FILES); echo " < /pre > "; 

原文地址:https://www.cnblogs.com/panxu/p/4730524.html