Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/15.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_Xml_Curl - Fatal编程技术网

使用Php curl获取/保存图像

使用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

我们正在使用PHP curl将图像保存到数据库中。我们从xml中获取图像的地址。录制图像后,我们遇到以下问题。图像重叠,记录不正确。或者将图像保存为带有名称的空白图像

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。我们将对文件格式进行限制。顺致敬意,