PHP CURL图像上传到远程系统
我正在使用以下代码PHP CURL图像上传到远程系统,php,curl,Php,Curl,我正在使用以下代码 $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_se
$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));
这里没有错误并显示成功消息,但实际上文件没有移动到目标
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, array( 'image' => '@' . $_FILES['image']['tmp_name'] ));
我这样做了,只设置了tmp_名称,如上所述。所以它应该可以工作。可能是权限问题?最好的选择是在本地保存它,并使用curl发送保存的图像url,在另一台服务器上使用curl从url获取图像使用域名而不是ip地址获取“永久移动”成功消息,但什么都没有发生“永久移动”表示您使用了错误的目标url,它不会接收您的文件,但会将您重定向到另一个URL,因此不会上载该文件。