Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Multiple File Upload
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Jason Macgowan  
View profile  
 More options Oct 18 2012, 7:22 pm
From: Jason Macgowan <jasonmacgo...@gmail.com>
Date: Thu, 18 Oct 2012 16:22:31 -0700 (PDT)
Local: Thurs, Oct 18 2012 7:22 pm
Subject: Multiple File Upload

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 must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andrey Kuzmin  
View profile  
 More options Oct 19 2012, 3:13 am
From: Andrey Kuzmin <Andre...@gmail.com>
Date: Fri, 19 Oct 2012 00:13:29 -0700 (PDT)
Local: Fri, Oct 19 2012 3:13 am
Subject: Re: Multiple File Upload

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.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jason Macgowan  
View profile  
 More options Oct 19 2012, 8:37 am
From: Jason Macgowan <jasonmacgo...@gmail.com>
Date: Fri, 19 Oct 2012 08:37:26 -0400
Local: Fri, Oct 19 2012 8:37 am
Subject: Re: [webpy] Re: Multiple File Upload
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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jason Macgowan  
View profile  
 More options Oct 19 2012, 10:00 am
From: Jason Macgowan <jasonmacgo...@gmail.com>
Date: Fri, 19 Oct 2012 10:00:27 -0400
Local: Fri, Oct 19 2012 10:00 am
Subject: Re: [webpy] Re: Multiple File Upload
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.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andrey Kuzmin  
View profile  
 More options Oct 19 2012, 10:04 am
From: Andrey Kuzmin <Andre...@gmail.com>
Date: Fri, 19 Oct 2012 07:04:44 -0700 (PDT)
Local: Fri, Oct 19 2012 10:04 am
Subject: Re: [webpy] Re: Multiple File Upload

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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jason Macgowan  
View profile  
 More options Oct 19 2012, 11:05 am
From: Jason Macgowan <jasonmacgo...@gmail.com>
Date: Fri, 19 Oct 2012 11:05:25 -0400
Local: Fri, Oct 19 2012 11:05 am
Subject: Re: [webpy] Re: Multiple File Upload
Works like a dream, as usual Andrey!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »