【发布时间】:2016-11-25 04:37:52
【问题描述】:
我正在尝试将图像从 VK 保存到文件夹。但是图像无法正确保存。
我使用的代码是:
// imageFromURL (Save an image from a URL)
function imageFromURL($url,$saveto){
$ch = curl_init ($url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);
$raw=curl_exec($ch);
curl_close ($ch);
if(file_exists($saveto)){
unlink($saveto);
}
$fp = fopen($saveto,'x');
fwrite($fp, $raw);
fclose($fp);
}
imageFromURL('https://vk.com/captcha.php?sid=698254154192&s=1', 'Image/Captcha.png');
我认为它一定不是标准的图像格式?我怎样才能保存它并确保它是带有 CURL 的 png 格式图像?
【问题讨论】:
-
当我运行它时,图像会正确保存到 Image 文件夹中。然后我就可以打开并查看它。是什么让你认为它没有节省?
-
这很奇怪,可能是php版本或允许的设置需要更改。