<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=iso-8859-1" http-equiv=Content-Type>
<META content="MSHTML 5.00.3502.5390" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Hi all </FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>import httplib, mimetypes<BR>import 
os;</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>def 
get_content_type(filename):<BR>    return 
mimetypes.guess_type(filename)[0] or 'application/octet-stream'</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>filepath= 'c:/Documents and 
Settings/Administrator/Desktop/tmp/test.pdf';<BR>f = open(filepath, 
"rb")<BR>data = f.read()<BR>f.close()</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>(filedir, filename) = 
os.path.split(filepath)<BR>filename=unicode(filename);<BR>#file = ('file', 
filename, data)  #This won't work will give a UnicodeDecodeError: 'ascii' 
codec can't decode byte 0xc7 in position 10: ordinal not in 
range(128)</FONT><FONT face=Arial size=2><BR>file = ('file', filename, 
'data'*100) #this will work fine<BR>#file = ('file', 'test.pdf', data) #This 
also works fine<BR>files = [file]<BR>CRLF = '\r\n'<BR>L = []<BR>for (key, 
filename, value) in files:<BR>    L.append('Content-Disposition: 
form-data; name="%s"; filename="%s"' % (key, filename))<BR>    
L.append(value)<BR>body = CRLF.join(L)</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>print "ok"</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>can anyone put some light.. whats going 
behind..</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>cheers</FONT></DIV>
<DIV><FONT face=Arial size=2>Thomas</FONT></DIV>
<DIV> </DIV>
<DIV> </DIV></BODY></HTML>