So I try to upload a file on a Remote Device.
If I use the Code:
#!/usr/bin/python
import httplib
import urllib2
from poster.encode import multipart_encode
from poster.streaminghttp import register_openers
import poster
register_openers()
params = {'restore': open("Config.cfg", "rb"), 'upload': 'PC ==>; Unit'}
datagen, headers = multipart_encode(params)
request = urllib2.Request('http://www.test.com/saveRestore.htm.cgi', datagen, headers)
u = urllib2.urlopen(request)
print u.read()
The file is Uploaded with the Content-Type text/plain ..
So how do I Change this content-type for example to text/html ?
Add:
headers['Content-Type'] = 'text/html'Before instantiating your Request object.