Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/270.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP CURL图像上传到远程系统_Php_Curl - Fatal编程技术网

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,因此不会上载该文件。