Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add how to show error for large uploads

  • Loading branch information...
commit b23e5ff5a5ac484745101a4ecd5f008e2f1890f8 1 parent 4e7d226
@anandology anandology authored
Showing with 10 additions and 1 deletion.
  1. +10 −1 cookbook/limiting_upload_size.md
View
11 cookbook/limiting_upload_size.md
@@ -21,4 +21,13 @@ The following code limits the size of input data to 10MB.
# 0 ==> unlimited input
cgi.maxlen = 10 * 1024 * 1024 # 10MB
-Please note that this limits the size of POST data, not file uploaded. However they will be almost same if there is no other input.
+Please note that this limits the size of POST data, not file uploaded. However they will be almost same if there is no other input.
+
+The `cgi` module raises `ValueError` when the input size is more than `cgi.maxlen`. It can be caught to display required error message.
+
+ class upload:
+ def POST(self):
+ try:
+ i = web.input(file={})
+ except ValueError:
+ return "File too large"
Please sign in to comment.
Something went wrong with that request. Please try again.