This is what I do to process multiple files:
i = web.webapi.rawinput()
files = i.uploadedfiles
if not isinstance(files, list):
files = [files]
for f in files:
# f.filename, f.file
On Friday, October 19, 2012 6:00:31 PM UTC+4, Jason Macgowan wrote:
>
> Just to make sure I'm asking what I'm trying to ask, consider the
> following HTML
>
> <form method="POST" enctype="multipart/form-data">
> <input type="file" name="uploadedfiles" />
> <input type="file" name="uploadedfiles" />
> <input type="submit" />
> </form
>
> This is bad markup, yes, but it's only to demonstrate the content of
> the POST request that Dojo's mutli uploader creates.
>
> My question is, how do I access the files from this POST request?
>
> web.input(uploadedfile={}) will only give me the last file
> web.input(uploadedfile=[]) will only give me a list of strings from the
> files
>
> I'm stumped, so any help is appreciated.
>
> On Fri, Oct 19, 2012 at 8:37 AM, Jason Macgowan
> <[email protected]<javascript:>>
> wrote:
> > Right, but the issue is that my uploaded file list is just a list with
> > strings. I need a way to access both of the uploaded files
> >
> > On Fri, Oct 19, 2012 at 3:13 AM, Andrey Kuzmin
> > <[email protected]<javascript:>>
> wrote:
> >> x is a storage object that web.input() returns. file or list of files
> is
> >> value of x.uploadedfiles. storage object is not for storing files, its
> >> basically a dict what values you can get via dot syntax.
> >>
> >>
> >> On Friday, October 19, 2012 3:22:31 AM UTC+4, Jason Macgowan wrote:
> >>>
> >>> I am using Dojo to upload multiple files to the server at once. It
> sends
> >>> a POST request to my Web.py app, submitting the files under the
> attribute
> >>> name 'uploadedfiles'.
> >>>
> >>> I try to catch and return these files with the following code:
> >>>
> >>> def POST(self):
> >>> x = web.input()
> >>> return x.uploadedfiles
> >>>
> >>> Works great with one file, but with 2 or more it returns only the last
> >>> file.
> >>>
> >>> I Read the Docs; says web.input uses a dict-like object, so the
> behavior
> >>> above makes sense.
> >>>
> >>> So reading up on things, I try:
> >>> def POST(self):
> >>> x = web.input(uploadedfiles=[])
> >>> return x.uploadedfiles
> >>>
> >>> Cool! Now it returns a list with both files! But it's just the file
> >>> itself. It's not a storage object like it would be if there was just
> one
> >>> file.
> >>>
> >>> My question is:
> >>>
> >>> Is there a way to return a list of storage objects from web.input()
> >>>
> >> --
> >> You received this message because you are subscribed to the Google
> Groups
> >> "web.py" group.
> >> To view this discussion on the web visit
> >> https://groups.google.com/d/msg/webpy/-/8S7bccaJ9ZsJ.
> >>
> >> To post to this group, send email to [email protected]<javascript:>.
>
> >> To unsubscribe from this group, send email to
> >> [email protected] <javascript:>.
> >> For more options, visit this group at
> >> http://groups.google.com/group/webpy?hl=en.
>
--
You received this message because you are subscribed to the Google Groups
"web.py" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/webpy/-/LxlMnUUNTi8J.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/webpy?hl=en.