is there a way to display image retrieved using php curl in the main page content

折月煮酒 提交于 2020-06-17 15:49:19

问题


i have two servers and i want to display image from my admin server to the client server. i have tried the following:

<img class="pop_image" onclick="window.location.href='<?php echo $pop_rslt['link_to'] ?>'" src="<?php echo imgCurl('odealsdev.in/crons2/fetch_image_by_name.php?name=exit_pop_up/'.$pop_rslt["pop_up_image"]);?>">

this is my client server. And i want to display the image from this location.the fetch_image_by_name.php looks like this

if(isset($HTTP_GET_VARS['name'])){
unset($file_headers);
$file_headers = @get_headers('https://sdev.in/administratie/images/' .$HTTP_GET_VARS['name']);
if($file_headers[0] != 'HTTP/1.1 404 Not Found'){
echo 'https://sdev.ekibo.nl/administratie/images/' .$HTTP_GET_VARS['name'];
}

}

and my curl function looks like this

function imgCurl($url){
  $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);

echo $raw;
}

but the main problem i mean the error i get is src='unknown'. pls someone help me to achieve this displaying images from my another server. i had gone through many stack results but non of them helped me to solve this since all are showing to download and display in separate page If i give the header type in curl as image/jpg then my whole page becomes a image type.please someone help me fix this

来源:https://stackoverflow.com/questions/62259796/is-there-a-way-to-display-image-retrieved-using-php-curl-in-the-main-page-conten

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!