>
> class upload(app.page):
> def __init__(self):
> self.file_dir = '/var/temp/'
>
self.file_uuid = str(uuid())
>
> def POST(self):
> data = web.input(myfile={})
> if 'myfile' in data:
> self.file_type = data.myfile.filename.replace('\\','/').split('.')[-1]
> if self.file_type not in ('jpeg', 'jpg', 'gif', 'png'):
> raise web.seeother('/photos', absolute=True)
> self.filename = self.file_dir+'/'+self.file_uuid+'.'+self.file_type
> self.save_file(data.myfile.file.read()) 
>
raise web.seeother('/photos', absolute=True) 
>
 
>
def save_file(self, data):
> fout = open(self.filename, 'w')
> fout.write(data)
> fout.close()
>

and 

<form role="form" method="POST" enctype="multipart/form-data" 
action="/upload">
    <input type="file" name="myfile" tabindex="1"/>
    <button type="button submit">Upload</button>
</form>

work for me

 

-- 
You received this message because you are subscribed to the Google Groups 
"web.py" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/webpy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to