updated docs to match new Werkzeug docs

This commit is contained in:
Nick Walker 2011-01-03 16:04:17 -08:00
parent 4c76607553
commit 10159e5464
7 changed files with 82 additions and 78 deletions

View file

@ -543,14 +543,14 @@ You can handle uploaded files with Flask easily. Just make sure not to
forget to set the ``enctype="multipart/form-data"`` attribute on your HTML
form, otherwise the browser will not transmit your files at all.
Uploaded files are stored in memory or at a temporary location on the
filesystem. You can access those files by looking at the
:attr:`~flask.request.files` attribute on the request object. Each
uploaded file is stored in that dictionary. It behaves just like a
standard Python :class:`file` object, but it also has a
:meth:`~werkzeug.FileStorage.save` method that allows you to store that
file on the filesystem of the server. Here is a simple example showing how
that works::
Uploaded files are stored in memory or at a temporary location
on the filesystem. You can access those files by looking at the
:attr:`~flask.request.files` attribute on the request object.
Each uploaded file is stored in that dictionary. It behaves just
like a standard Python :class:`file` object, but it also has a
:meth:`~werkzeug.datastructures.FileStorage.save` method that allows you
to store that file on the filesystem of the server. Here is a simple
example showing how that works::
from flask import request
@ -561,16 +561,16 @@ that works::
f.save('/var/www/uploads/uploaded_file.txt')
...
If you want to know how the file was named on the client before it was
uploaded to your application, you can access the
:attr:`~werkzeug.FileStorage.filename` attribute. However please keep in
mind that this value can be forged so never ever trust that value. If you
want to use the filename of the client to store the file on the server,
pass it through the :func:`~werkzeug.secure_filename` function that
Werkzeug provides for you::
If you want to know how the file was named on the client
before it was uploaded to your application, you can access the
:attr:`~werkzeug.datastructures.FileStorage.filename` attribute. However
please keep in mind that this value can be forged so never ever trust that
value. If you want to use the filename of the client to store the file
on the server, pass it through the :func:`~werkzeug.utils.secure_filename`
function that Werkzeug provides for you::
from flask import request
from werkzeug import secure_filename
from werkzeug.utils import secure_filename
@app.route('/upload', methods=['GET', 'POST'])
def upload_file():