0
我想图像保存到这个'http://198.164.241.108/~bss/api/images/upload_images';
位置PHP图片上传到远程服务器
我尝试以下
$url = 'http://198.164.241.108/~bss/api/images/upload_images';
$img = $_FILES['image']['tmp_name'];
file_put_contents($img, file_get_contents($url));
使用curl
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, array('file' => $_FILES["image"]["tmp_name"]));
curl_setopt($ch, CURLOPT_URL, '`http://198.164.241.108/~bss/api/images/upload_images`');
curl_exec($ch);
curl_close($ch);
但是这两个不工作
当然,它不会工作 - 你需要模拟表单提交。实现它的最好方法 - 借助cURL函数。分析从表单发送的数据和http://stackoverflow.com/questions/3085990/post-a-file-string-using-curl-in-php – Cheery 2014-10-07 06:17:52