I'm receiving the same error as well, and I am following the web.py 
cookbook to the tea. Has anyone found the solution yet?

On Wednesday, January 2, 2013 1:35:27 AM UTC-6, [email protected] wrote:
>
> i need help uploading and storing files with web.py  
>
> this is my code so far 
>
>
> import web
>
> urls = (
>     '/hello', 'index',
>     '/hello/upload', 'upload'
> )
> app = web.application(urls, globals()) # handels http request  that aks 
> for urls 
> # the base ells lpthw.web to use the templates/layout.html file as the 
> base template for all the other templates
> render = web.template.render('templates/', base="layout")
> # must use port 127.0.0.1:5000
> class index(object):
>     
>     def GET(self):
>         return render.hello_form()
>         
>     def POST(self):
>         form = web.input(name="Nobody", greet="Hello")
>         greeting = "%s, %s" % (form.greet, form.name)
>         return render.index(greeting = greeting)
>
> class upload(object):
>     
>     def POST(self):
>         x = web.input(files={})
>         
>         filedir = '/project/webtest/templates'  # directory were you want 
> to save the file 
>         if 'files' in x:  # check if the file -object is created
>             filepath=x.files.filename.replace('\\','/') # replace the 
> windows -style slashes with linux ones
>             filename=filepath.split('/')[-1] #splits the and chooses the 
> last part (the filename with extension
>             fout = open(filedir +'/'+ filename,'w') # creates the file 
> where the uploaded file should be stored
>             fout.write(x.files.file.read()) #writes the uploaded file to 
> the newly created file.            
>             fout.close() #closes the file 
>         else:
>             return "Error no file" 
>             
>             
> if __name__ == "__main__":
>     app = web.application(urls, globals()) 
>     app.run() 
>
>
> i keep geting a 
> <type 'exceptions.IOError'>
>
> help :O
>

-- 
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/groups/opt_out.

Reply via email to