【发布时间】:2014-12-01 12:06:32
【问题描述】:
我想把图片保存到这个'http://198.164.241.108/~bss/api/images/upload_images';location
我尝试了以下
$url = 'http://198.164.241.108/~bss/api/images/upload_images';
$img = $_FILES['image']['tmp_name'];
file_put_contents($img, file_get_contents($url));
使用卷曲
$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 函数的帮助下。分析表单发送的数据和stackoverflow.com/questions/3085990/…
标签: php