Probably the easiest way to save the file is to do something like
this:
f = open('file_to_write', 'w')
f.write(x['myfile'].value)
f.close()
On Feb 24, 12:54 am, Tzury Bar Yochay <[EMAIL PROTECTED]> wrote:
> > But how do you copy the file to its destination?
> > I tried many ways, such as this, with no result:
>
> > def POST(self):
> > x = web.input(myfile={})
> > web.debug(x['myfile'].value) # This is the file contents
> > web.debug(x['myfile'].filename) # This is the filename
>
> > out = open(x['myfile'].filename,'wb')
> > import shutil
> > shutil.copyfileobj(x, out)
>
> > web.redirect('/upload')
>
> Not sure but speculating.
> You are using copyfileobj which copy data from file-like object fsrc
> to file-like object fdst.
> However, web.input(myfile={}) does not return a strict file object
> I would have try out.write() or out.writelines() depends on the case
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web.py" group.
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
-~----------~----~----~----~------~----~------~--~---