urllib2 file upload error
Thomas
thomas at eforms.co.nz
Wed Apr 27 23:45:50 EDT 2005
More information about the Python-list mailing list
Wed Apr 27 23:45:50 EDT 2005
- Previous message (by thread): pyqt and Eric 3
- Next message (by thread): urllib2 file upload error
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
import urllib2 URL = 'http://xxx.xxx.xxx.xxx/UploaderHttp/' FILE= 'c:/Documents and Settings/Administrator/Desktop/Vousleve 1 .pps'; d = [ ('cmd', 'add-item'), ('protocol_version', '2.1'), ('userfile', open(FILE)), ] req = urllib2.Request(URL, d) try: u = urllib2.urlopen(req) except urllib2.HTTPError, errobj: print "HTTPError:", errobj.code else: buf = u.read() print "OK" Python 2.3.4 (#53, May 25 2004, 21:17:02) [MSC v.1200 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> ## working on region in file c:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/python-1396n5Q.py... Traceback (most recent call last): File "<stdin>", line 1, in ? File "c:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/python-1396n5Q.py", line 11, in ? u = urllib2.urlopen(req) File "c:\Python23\lib\urllib2.py", line 129, in urlopen return _opener.open(url, data) File "c:\Python23\lib\urllib2.py", line 326, in open '_open', req) File "c:\Python23\lib\urllib2.py", line 306, in _call_chain result = func(*args) File "c:\Python23\lib\urllib2.py", line 901, in http_open return self.do_open(httplib.HTTP, req) File "c:\Python23\lib\urllib2.py", line 888, in do_open h.send(data) File "C:\Python23\lib\httplib.py", line 576, in send self.sock.sendall(str) File "<string>", line 1, in sendall TypeError: sendall() argument 1 must be string or read-only buffer, not list Tried the script from http://fabien.seisen.org/python/urllib2_multipart.html also Getting similar error.. Cheers Thomas -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-list/attachments/20050428/d211b5d5/attachment.html>
- Previous message (by thread): pyqt and Eric 3
- Next message (by thread): urllib2 file upload error
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list