mengu on web programming.

Werkzeug File Uploads

I have been meaning to write about how to implement werkzeug file uploads before how to do file uploads with TurboGears because this is the top search engine query that my visitors are coming from and the fact that they cannot find what they search on my blog is really bothering me so here it is.

The same logic like the TurboGears version applies to Werkzeug. The only difference is that Werkzeug doesn't store the files within the request.params or request.form but it stores the files in request.files as FieldStorage.

If you read the code carefully you will see there is a function that I have used named "secure_filename". This method simply returns a secure filename so you can store the file safely in your file system. This is actually for the files that you will be saving to your file system.

If you wonder how you can save uploaded files to your database, you can simply use the save method.

Hope this post helps some of you out and I can feel better now. Leave your comments and have your say.

Comments

No comments made for this post.

Leave a Response

No HTML allowed. You can use markdown.
Name*:
E-Mail* (not published):
Web site:
Response: