Problem saving uploaded files in Python3

hidura at gmail.com hidura at gmail.com
Sat Oct 2 08:13:23 CEST 2010


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.
for cont in range(5,150):#Now beging in the 5th position to the 150th  
position
s.write(dat[cont])#Insert the piece of the data in the file.
s.close()#Then closed.

Where is the mistake?

Thankyou in advance.

--
Diego Hidalgo D.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20101002/a5499615/attachment.html>


More information about the Python-list mailing list