I'm trying to write a python script that will upload a file and changing its mime-type
from poster.encode import multipart_encode, MultipartParam
from poster.streaminghttp import register_openers
import urllib2
register_openers()
params = [MultipartParam('img', open("data.mp4", "rb").read(), filetype='image/jpeg')]
datagen, headers = multipart_encode(params)
request = urllib2.Request("http://localhost:8082/uploader.php", datagen, headers)
print urllib2.urlopen(request).read()
The uploader is dumping the $_POST and $_FILES in the document. The video that I'm uploading is going in the $_POST
and not in $_FILES
I'm having a hard time to know how to make it work
EDIT:
The php code just dumps the files and posts:
var_dump($_POST);
var_dump($_FILES);
However as mentioned above, the file appears in the dump of the $_POST not the $_FILES
This is what PHP is returning:
FILES:
array(0) {
}
POST:
array(1) {
["img"]=>
string(82038) "-- Content of video was here, removed because it's too long --"
}