Problem saving uploaded files in Python3

hidura at hidura at
Sat Oct 2 16:37:21 CEST 2010

The results was that, i can upload all the data normally comes as an byte  
code and looks like this:

\\x00IDATx\\xda\\xec\\xddw\\x9cT\\xd5\\xf9\\xf8\\xf1\\xcf\\xbd\\xd3g{_v\\x97\\xde\\x9b]\\xb0!\\x8a\\x05\\x14\\xbbFE\\xe37\\xc6\\xfaK\\x8c\\x9a\\x18\\x13\\x13c\\x8b\\x1a\\x13Mb\\x8a\\xb1D,\\xb1\\x1b\\x0b\\x8aDbE\\xac\\x18D\\x94*(}Y\\xb6\\xf7\\xd9\\xa9\\xf7\\x9e\\xf3\\xfbcf+\\xdb\\xc0U\\x97\\xe5y\\xbf^\\xe3\\xee\\xce\\xbd\\xa7\\xdcs\\xcf\\x1d\\x9d\\xc7S\\x0c\\x80\\xf7\\xbf\\xaa\\xd4e\\xf5ab\\xb6F\\x08\\xf1\\xdds9\\x0c\\xf2R\\xbd\\xec78\\x9d\\x14\\xafS\\x1aD\\x08!\\x84\\x10B\\x88\\x01\\xe0\\x99\\xa5\\xc5\\xd2\\x08B\\xf43J\\xd9h\\xa5 at k\\xbe\\x89\\xa8\\x98\\x01`\\x18\\x18\\xa6\\x89i:\\xa4\\xc1\\x07\\x10\\'@f\\x92\\x9b\\xfd\\x06\\xa7\\xe1s\\xc9\\xcd\\x15\\xa2?\\x08\\xc5l\\xb6V\\x87x\\xeb\\x8b\\nfN\\xcc\\xc3\\xef\\x96gS\\x08!\\x84\\x10B\\x08!\\x84\\xe8K\\xca\\x8a\\xa1\\xeb\\xb7\\xa3\\xcb\\xd7\\xa0C\\xb5\\xa0\\x15\\x00\\xee\\xa4\\x0c\\xb0c}S\\x88a\\x827

and this is what i store in the file, and the part of the code what handle  
the wsgi it's that what i post, i am using to test the upload file area, i  
hope this is what you want

Thanks for the answer!!!!
On Oct 2, 2010 5:34am, "Diez B. Roggisch" <deets at> wrote:
> Chris Rebert clp2 at> writes:

> > On Fri, Oct 1, 2010 at 11:13 PM, hidura at> wrote:

> >> Hello, i control the problem of the data what is uploaded by the POST

> >> method, in the web if the file is a text theres no problem

> >> but the trouble comes when it's an enconded file as a Picture or other  
> what

> >> the when the system insert the data into the file

> >> well it doesn 't encoded in the write way i will put all the code,  
> from the

> >> area whats take the environ['wsgi.input'] to the area

> >> thats save the file:

> >>

> >> tmpData = str(rawData)[1:].strip("' '")#Here the data from the

> >> environ['wsgi.input'], first i convert the byte into a string delete  
> the

> >> first field that represent the b and after i strip the single quotes

> >> dat = tmpData.split('\\r')#Then i split all the data in the '\\r'

> >> s = open('/home/hidura/test.png', 'w')#I open the test.png file.

> >

> >> Where is the mistake?

> In believing that wsgi.input is a simple file that contains your

> upload. It isn't. It is multipart/form-data encoded, to cope with

> potentially many files being uploaded in one go, plus assorted other

> form fields.

> In another post, you have already been shown how to do this. What where

> the results? How does your full script look like? How does the form look

> like you upload with?

> Diez

> --


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list