If the user does not select the file in the form (equals PHP UPLOAD_ERR_NO_FILE ), it request.files['file']also returns the object FileStorageI use request.files['file'].filename == ''to check if it is better? I saw the Flask Doc but cannot find the answer.
request.files['file']
FileStorage
request.files['file'].filename == ''
'file' in request.files will not work for the user, does not select the file, the browser will also send 0 length and the file name is equal to '' (empty line).
'file' in request.files
and how can I detect the downloaded file, the error was only partially downloaded (equal to PHP UPLOAD_ERR_PARTIAL )?
Now i use
if request.files['file'].filename == '': return 'No selected file'
or by checking file length
import os file = request.files['file'] file.seek(0, os.SEEK_END) if file.tell() == 0: return 'No selected file'
Try:
if not request.files.get('file', None): pass
, http://pythonhosted.org/Flask-Uploads/
Source: https://habr.com/ru/post/1540155/More articles:Ruby on Rails Mac OSX Mavericks quits after installing RVM - ruby | fooobar.comWhy does the html element not occupy the entire browser of the browser? - htmlGetting task results from synchronous execution - c #Performance Issues Delphi FireMonkey Canvas - delphiIn Meteor JS, how to control Javascript load order in relation to DOM load order? For animations - javascriptorder_by in the Many-to-many field leads to duplicate records in the query set - djangoElixir: overloading functions with varying clarity - functionЧистая поддержка тегов HTML 5 в JSF 2 - html5Inactive location agent - androidCreating an interactive div with the syntax 'link_to' - htmlAll Articles