php - Getting an 'html' type instead of 'image' from the browser -
i'm using curl fetch image file our server. after checking browser's developer tools, says returned type 'html' instead of 'image'.
here's response:
/f/gc.php?f=http://www.norbert.com/get/image/bts-005-00.jpg 200 text/html 484.42 kb 1.68 s <img>
here's curl script:
$ch = curl_init(); $strurl = $strfile; curl_setopt($ch, curlopt_url, $strurl); curl_setopt($ch, curlopt_useragent, "mozillaxyz/1.0"); curl_setopt($ch, curlopt_header, 0); curl_setopt($ch, curlopt_returntransfer, true); curl_setopt($ch, curlopt_timeout, 60); $output = curl_exec($ch); curl_close($ch); return $output;
any additional specific code add in curl script?
thanks!
your php script doing curl , returning output without specific header of image.
so, default, browser retrieve data html content.
try add more specific header before returning output.
try
header('content-type: image/jpg');
to specify browser type of content script sending.
if want user able download file, can add header:
header('content-disposition: attachment; filename="' . $filename . '";');
if sending binary content, add:
header("content-transfer-encoding: binary");
Comments
Post a Comment