0

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

pukka
  • 45
  • 6
  • could just base64 inline it (bad practice, slow & memory & bandwidth-hungry & cache-unfriendly, but it works) – hanshenrik Jun 08 '20 at 10:20
  • @hanshenrik when i use like this as u have just said my server won't allow ..it's creates security issue. that's y i choose to use the curl but i want to just ping the server so that i can get the src and use it well in live – pukka Jun 08 '20 at 10:29
  • isn't this very simple ? `Girl in a jacket` –  Jun 08 '20 at 10:42
  • @Dlk really it is but it will not work in my server.but it does work in my development server – pukka Jun 08 '20 at 10:55
  • This will answer your question : https://stackoverflow.com/a/27702621/12232340 –  Jun 08 '20 at 12:58
  • @Dlk i used this link before but my website becomes image type. it has become like the image not as web page since the header type is defined image so it acts like this – pukka Jun 08 '20 at 13:12
  • @SabujHassan could u pls help – pukka Jun 08 '20 at 14:52
  • @Walf could u pls help – pukka Jun 08 '20 at 14:53

0 Answers0