Not getting all keys in FieldStorage (Multipart form data)

vivek kumar gupt_vive at
Wed Jun 4 14:26:51 CEST 2003

>From: "Graeme Matthew" <gsmatthew at>
>To: "vivek kumar" <gupt_vive at>
>Subject: Re: Not getting all keys in FieldStorage (Multipart form data)
>Date: Wed, 4 Jun 2003 22:06:53 +1000
>Keeping that in mind try this:
>import shutil
>BUFFER = 1024
>file = form['book_image'].file                         #this will be a  
>handle in FieldStorage
>destination = open('C;/help.jpeg','wb')           #This will be destinate
>file (might need to create it first)
>shutil.copyfileobj(file,destination,1024)           #Copy file to file

I tried this also. But it works with the text files but it does not save 
binary files successfully :-(. Here is the code I used as you suggested

if form.has_key("aimsfile"):

    from shutil import copyfileobj

    from os.path import splitext
    from shutil import copyfileobj

        savefile=open("1.%s" %ext,"wb")
    except Exception,e:
        print "Not saved..",str(e)

>Hope this helps ?

TIA and Kind Regards
Vivek Kumar

HCL Beanstalk PCs. You could win one. Interested?

More information about the Python-list mailing list