Please paste the code for the form. The input for file should be:
   <input type="file" name="myfile">
You could view the source of the page and check if name=='myfile' and you
can put a "print temp" after temp=web.input... to see what data you have.




On Thu, Jun 6, 2013 at 7:15 AM, Joseph Do <[email protected]> wrote:

> I am trying to upload images and here is my code for handling file upload:
>
> def POST(self):
>>         temp = web.input(myfile={})
>>         filedir = '/home/daidq/web.py/upload/images'
>>         if 'myfile' in temp:
>>             filepath = temp.myfile.filename.replace('\\','/')
>>             filename = filepath.split('/')[-1]
>>             fout = open(filedir +'/'+ filename,'w')
>>             fout.write(temp.myfile.file.read())
>>             fout.close()
>>         raise web.seeother('/gallery')
>>
>
> But the problem is that it keeps show me error: *name 'temp' is not
> defined* at *if 'myfile' in temp:* line
>
> Please help me to get over this.
>
> --
> 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?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
This message is confidential. It may also be privileged or otherwise
protected by work product immunity or other legal rules. If you have
received it by mistake please let me know by reply and then delete it from
your system; you should not copy the message or disclose its contents to
anyone.

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to