Cleaning some (web upload based) garbage

This commit is contained in:
Miroslav Stampar
2012-12-13 13:19:47 +01:00
parent 5150172178
commit df0f08bc6a
6 changed files with 26 additions and 41 deletions

View File

@@ -87,7 +87,7 @@ class MultipartPostHandler(urllib2.BaseHandler):
for (key, fd) in files:
file_size = os.fstat(fd.fileno())[stat.ST_SIZE] if isinstance(fd, file) else fd.len
filename = fd.name.split('/')[-1]
filename = fd.name.split('/')[-1] if '/' in fd.name else fd.name.split('\\')[-1]
contenttype = mimetypes.guess_type(filename)[0] or 'application/octet-stream'
buf += '--%s\r\n' % boundary
buf += 'Content-Disposition: form-data; name="%s"; filename="%s"\r\n' % (key, filename)