you can get the file content from

  request.vars.my_field_name.file.read()

and the file name from

  request.vars.my_field_name.filename

hope this helps.

On Mar 12, 7:55 pm, Joe  Barnhart <joe.barnh...@gmail.com> wrote:
> Let me preface this by explaining that I am a noob at creating
> websites.  This is probably so simple that anyone who's been around
> the block knows the answer and is thus confused at the empty-
> headedness of my question.
>
> I wanted to take advantage of web2py's built-in handling of update
> fields -- it pops up a file chooser and allows the user to pick the
> the file to upload on his local computer.  The file is then streamed
> up to the server running web2py and usually placed in the "uploads"
> directory and linked into a database table.  In my case, rather than
> storing the file or a reference to it in a database, I wish to process
> the file immediately in the controller and store the processed
> results.
>
> I can create a form using form_factory with a single SQLField
> definition for a field of type "upload".  When I invoke this form it
> correctly displays a file chooser and lets me pick a file.  After that
> -- nothing.  The form.accepts() part of the controller is never
> triggered.  I can look at the contents of the
> request.vars.my_field_name and see that it now contains an object of
> FieldStorage, but I'm not sure what it is good for.
>
> Thank you for your patience and responses.
>
> On Mar 12, 5:23 pm, Wes James <compte...@gmail.com> wrote:
>
> > On Thu, Mar 12, 2009 at 6:20 PM, Joe Barnhart <joe.barnh...@gmail.com> 
> > wrote:
>
> > > Actually, I need to process the CSV file before it can be inserted
> > > into the database.  I was hoping to upload it to disk (or even memory
> > > as the files are small), do the processing, and commit the changes to
> > > db.
>
> > How about uploading it to the static files folder in web2py admin then
> > process if from there?  Not sure what you are trying to do though??
> > upload via browser or copy over via sftp? then process??
> > -wj
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to