Reputation: 41
I am developing an upload multiple files with Python + Tornado + Nginx Web Server. I have changed the properties of the Nginx server as follows:
client_body_buffer_size 512K; client_max_body_size 500M;
However, when sending a quantity greater than 3 files, it does not forward the room. What could be happening?
On the internet and even here on Stack Overflow only examples with a single file, or against, creating multiple
The code is below:
Python
class UploadHandler(tornado.web.RequestHandler):
def post(self):
try :
t = len(self.request.files)+1
x = 0
n = 'file'
while x <= t:
nn = self.request.files[n][x]
nome_arquivo = nn['filename']
output_file = open("my directory/" + nome_arquivo, 'w')
output_file.write(nn['body'])
x+=1
self.render(
"sucess.html"
)
except IndexError:
self.render(
"sucess.html"
)
HTML
<form enctype="multipart/form-data" method="post" action="/uploads">
<input name="descricao" type="text" /> <br>
<input type="file" name="file" multiple />
<input type="submit" value="Send File(s)">
</form>
Upvotes: 0
Views: 1168
Reputation: 41
Friends, i solved it creating one index. Before, didn't have it.
Final resolution:
class UploadHandler(tornado.web.RequestHandler):
def post(self):
try :
t = len(self.request.files)
x = 1
indice = 0
n = 'file'
while x <= t:
nn = self.request.files[n][indice]
nome_arquivo = nn['filename']
output_file = open("static/arquivos/" + nome_arquivo, 'w')
output_file.write(nn['body'])
indice+=1
self.render(
"sucess.html"
)
except IndexError:
self.render(
"sucess.html" # this necessary but command while don't achieved implement
) # x+=1 - i don't know why...
# with this resolution, an error will be showed but redirected
# at the same if success
Upvotes: 1