我在PHP中使用curl从另一个网站获取图像,输出不可读。这就像+�<�@�9�3�*zB�<�4�<�I�;�4�2�;�3xO�
。我在XAMPP上使用php7。
$ch = curl_init();
$option = array(
CURLOPT_USERAGENT => $user_agent,
CURLOPT_ENCODING => '',
CURLOPT_URL => $url,
CURLOPT_HEADER => true,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_RETURNTRANSFER => true
);
curl_setopt_array($ch, $option);
$response = curl_exec($ch);
$responseInfo = curl_getinfo($ch);
$headerSize = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
curl_close($ch);
print_r($response);
答案 0 :(得分:0)
header('Content-type: image/jpeg');