Skip to content
Myr

fixing cross-referenced links on fileupload patterns page

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by matt swanson · committed by matt swanson · parent 6bdde49 · Browse files · 1 file+4 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+4 added−4 removed

  • other:+4 added−4 removed

1 file+4 added−4 removed

modified:docs/patterns/fileuploads.rst+4 added-4 removed
8 unmodified lines
91. A ``<form>`` tag is marked with ``enctype=multipart/form-data``10 and an ``<input type=file>`` is placed in that form.112. The application accesses the file from the :attr:`~flask.request.files`12 dictionary on the request object.133. use the :meth:`~werkzeug.FileStorage.save` method of the file to save133. use the :meth:`~werkzeug.datastructures.FileStorage.save` method of the file to save14 the file permanently somewhere on the filesystem.1516A Gentle Introduction17---------------------
52 unmodified lines
70 <input type=submit value=Upload>71 </form>72 '''7374So what does that :func:`~werkzeug.secure_filename` function actually do?74So what does that :func:`~werkzeug.utils.secure_filename` function actually do?75Now the problem is that there is that principle called "never trust user76input". This is also true for the filename of an uploaded file. All77submitted form data can be forged, and filenames can be dangerous. For78the moment just remember: always use that function to secure a filename79before storing it directly on the filesystem.8081.. admonition:: Information for the Pros8283 So you're interested in what that :func:`~werkzeug.secure_filename`83 So you're interested in what that :func:`~werkzeug.utils.secure_filename`84 function does and what the problem is if you're not using it? So just85 imagine someone would send the following information as `filename` to86 your application::87
20 unmodified lines
108 return send_from_directory(app.config['UPLOAD_FOLDER'],109 filename)110111Alternatively you can register `uploaded_file` as `build_only` rule and112use the :class:`~werkzeug.SharedDataMiddleware`. This also works with112use the :class:`~werkzeug.wsgi.SharedDataMiddleware`. This also works with113older versions of Flask::114115 from werkzeug import SharedDataMiddleware116 app.add_url_rule('/uploads/<filename>', 'uploaded_file',
64 unmodified lines