Not getting all keys in FieldStorage (Multipart form data)

vivek kumar gupt_vive at hotmail.com
Wed Jun 4 13:32:22 CEST 2003


>From: "Graeme Matthew" <gsmatthew at ozemail.com.au>
>To: "vivek kumar" <gupt_vive at hotmail.com>
>Subject: Re: Not getting all keys in FieldStorage (Multipart form data)
>Date: Wed, 4 Jun 2003 20:27:23 +1000
>
>Hi vivek
>
>Mate, what happens if you try
>
>if form.has_key('book_image')
>     file = form['book_image'].file

OK, here is my code with which I am trying to load image after trying as you 
suggested..

form=cgi.FieldStorage()
if form.has_key("book_image"):
    loadfile=form["book_image"].file
    #id=form["bookid"].value
    id="1"
    from os.path import splitext
    ext=os.path.splitext(form["book_image"].filename)[1][1:]
    try:
        savefile=open("%s.%s" %(id,ext),"wb")
        savefile.write(loadfile.read())
        savefile.close()
        .....<printing positive response>...
    except Exception,e:
        ....<logging error and negative response>...
        print "Not saved..",str(e)
        pass

>also remember you will need to base 64 encode it i.e binary

May be this is the problem. But I don't know how to do that :-( I have 
searched on the net also but was unable to find any information :-(. Can you 
Please tell me how to set the base encoding??

>Does this help ?

Thanks and Kind Regards
Vivek Kumar

_________________________________________________________________
Race along with NK. The fastest Indian 
http://server1.msn.co.in/sp03/tataracing/index.asp Feel the thrill!






More information about the Python-list mailing list