When there are multiple <input type="file" name="fname"> with the same name, web.input(fname={}) only returns the last one.
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
web.py |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
In webpy .34 release.
When there are multiple <input type="file" name="fname"> with the same name, web.input(fname={}) only returns the last one.
This happens to be how: <input type="file" multiple=""> submits it's files.
(works in ff3.6 & recentish chrome/safari)
My fix for this is in utils.py storify() line 147: change
else:
value = value[-1]
TO:
elif not isinstance(
value = value[-1]
Related Suggested Change:
I hate having todo: web.input(email=[], phone=[], userfile={}) to get lists when I have multiple form elements with the same name.
Why not be able to do something like this: web.input(
defaults.
and in utils.py storify() add:
_nolists = defaults.
… and ...
elif _nolists and not isinstance(
value = value[-1]
That forces returning FieldStorage objects (instead of their .value) when you do web.input(
A cleaner way to add this might be an input() wrapper something like web.inputs() which always returns lists for fields with the same name.
Let me know what you think about something like that.
-hudlee [<email address hidden>]
tags: | added: file forms upload |
tags: |
added: file-upload removed: file upload |
description: | updated |
summary: |
- When there are multiple <input type="file"> with the same name, - web.input() only returns the last one. + When there are multiple <input type="file" name="fname"> with the same + name, web.input(fname={}) only returns the last one. |
description: | updated |
description: | updated |
description: | updated |
description: | updated |
description: | updated |
Changed in webpy: | |
status: | New → Fix Released |
This is how I would do it. Anyone like/hate this idea?