我正在使用以下代码
$ch = curl_init("http://198.155.239.118/~bulacs/ssapi-staging/images/upload_images");
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (X11; Linux x86_64; rv:21.0)Gecko/20100101 Firefox/21.0");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt(
$ch,
CURLOPT_POSTFIELDS,
array(
'image' =>
'@' . $_FILES['image']['tmp_name']
. ';filename=' . $_FILES['image']['name']
. ';type=' . $_FILES['image']['type']
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
var_dump(curl_exec($ch));
此处没有错误并显示成功消息,但实际上文件未移至目的地。
答案 0 :(得分:0)
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, array( 'image' => '@' . $_FILES['image']['tmp_name'] ));
我这样做了,我只设置了tmp_name,就像上面一样。所以它应该有用。