使用Php curl获取/保存图像
我们正在使用PHP curl将图像保存到数据库中。我们从xml中获取图像的地址。录制图像后,我们遇到以下问题。图像重叠,记录不正确。或者将图像保存为带有名称的空白图像使用Php curl获取/保存图像,php,xml,curl,Php,Xml,Curl,我们正在使用PHP curl将图像保存到数据库中。我们从xml中获取图像的地址。录制图像后,我们遇到以下问题。图像重叠,记录不正确。或者将图像保存为带有名称的空白图像 function resim($link, $klasor, $dosya) { if (!file_exists($klasor)) { mkdir($klasor); } $type = strtolower(substr(strrchr($link,"."),1)); if
function resim($link, $klasor, $dosya)
{
if (!file_exists($klasor)) {
mkdir($klasor);
}
$type = strtolower(substr(strrchr($link,"."),1));
if ($type == 'jpeg') {
$type = 'jpg';
}
$resim = fopen("{$klasor}/{$dosya}.{$type}", 'w');
$ch = curl_init($link);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_NOPROGRESS, false );
curl_setopt($ch, CURLOPT_FILE, $resim );
curl_exec($ch);
curl_close($ch);
fclose($resim);
}
- 我们在哪里犯错误?或者我们可以用另一种方式吗
- 我们如何获得图像完成信息
尊敬的各位。这取决于处理上传功能的API。您可能向API传递了错误的图像格式。例如,它可能接受图像的base64内容Alaa Attia Mohamed。我们将对文件格式进行限制。顺致敬意,