Reputation: 3538
I have created an upload form and want to keep track of the files that I have uploaded.
<form action="http://localhost:5000/add_csv_to_db" method='POST' enctype="multipart/form-data">
<input type="file" name="csv_file" accept="*">
<input type="submit">
</form>
I have control of both client/server and this is just for my own use.
Is there a way to set name="csv_file"
to be the name of the file? I have 100+ files I need to upload and want to keep track of which ones I've uploaded.
Thanks!
Upvotes: 0
Views: 22
Reputation: 3538
Found the answer
if 'csv_file' not in request.files:
return 'didnt work'
f = request.files['csv_file']
print(f.filename)
Upvotes: 1
Reputation: 155085
There is no need for this. multipart/form-data
includes the file-name in the MIME-part header.
In ASP.NET, it's exposed via the HttpPostedFileBase.FileName
property: https://msdn.microsoft.com/en-us/library/system.web.httppostedfilebase.filename(v=vs.110).aspx
Upvotes: 0