Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/302.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/backbone.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 请求-发布多个文件_Python_Python Requests - Fatal编程技术网

Python 请求-发布多个文件

Python 请求-发布多个文件,python,python-requests,Python,Python Requests,在html中: <form action="/addCar" method="post" enctype="multipart/form-data"> many inputs (text, email, etc) <input type="file" accept="image/*" name="files[]"> <input type="file" accept="image/*" name="files[]"> <in

在html中:

   <form action="/addCar" method="post" enctype="multipart/form-data"> 
   many inputs (text, email, etc)

   <input type="file" accept="image/*" name="files[]">
  <input type="file" accept="image/*" name="files[]">
  <input type="file" accept="image/*" name="files[]">
  <input type="file" accept="image/*" name="files[]">
  <input type="file" accept="image/*" name="files[]">
   </li>

  </form>
但它只上传
2.jpg
。如何修复它


谢谢。

您正在覆盖这些名称。让它与众不同:

files = {
    'file1': open('img/1.jpg', 'rb'), 
    'file2': open('img/2.jpg', 'rb')
}
或者将其放在列表中:

files = {
    'files': [open('img/1.jpg', 'rb'), open('img/2.jpg', 'rb')]
}

你正在覆盖这些名字。让它与众不同:

files = {
    'file1': open('img/1.jpg', 'rb'), 
    'file2': open('img/2.jpg', 'rb')
}
或者将其放在列表中:

files = {
    'files': [open('img/1.jpg', 'rb'), open('img/2.jpg', 'rb')]
}

files={'files':[open('img/1.jpg','rb'),open('img/2.jpg','rb')])
-
TypeError:需要字符串或缓冲区
请尝试第一个,我不知道你在做什么样的请求。如果先没有上传图像,你能解释一下你在做什么样的请求,服务器需要什么样的请求吗?
files={'files':[open('img/1.jpg','rb'),open('img/2.jpg','rb')]}
-
TypeError:expected string或buffer
试试第一个,我不知道你提出了什么样的请求。如果首先-没有上传图像,你能解释一下你提出了什么样的请求,服务器需要什么样的请求吗?你必须发送5个不同的请求才能完成,你不能一次发送所有的请求。所以,我只能发送一个文件?我想是的,
request.session
不支持它。您必须发送5个不同的请求才能完成此任务,您不能一次发送所有请求。所以,我只能发送一个文件?我想是这样,
request.session
不支持它。