我正在尝试编写一个python脚本,它将上传文件并更改其mime类型
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()
上传者正在将$ _POST和$ _FILES转储到文档中。我上传的视频位于$_POST
而非$_FILES
我很难知道如何让它发挥作用
编辑:
php代码只是转储文件和帖子:
var_dump($_POST);
var_dump($_FILES);
但是如上所述,该文件出现在$ _POST的转储中而不是$ _FILES
这就是PHP的回归:
FILES:
array(0) {
}
POST:
array(1) {
["img"]=>
string(82038) "-- Content of video was here, removed because it's too long --"
}