Get external website image as data:image/jpeg;Base64

Asked

Viewed 1,686 times

1

Is it possible to save an image as an external website date using javascript or php? because this was the only way I could get q the image to appear in the browser, when inspecting this is the way:

http://appsite/caminho/camio2/Content/camio3/Painelimg/2018_03_02/08_03_28.PNG

But when play directly in the browser the image turns black, only q on the company website it is black but contains numbers, should be canvas, I can only see these numbers when I saved with the right mouse button and click on "save image as:" or another way was to open the image in the sources panel and copy the image as URI ai data pasted in the browser and there was the image perfectly, the code turns black too.

NOTE: this image changes every 10 seconds I need my browser to update automatically and take the next image. (the name of the image is the current time H_M_S.PNG or this was at 08h 03m and 28s.

1 answer

1

Translating from Stackoverflow english:

If you have allow_url_fopen set as true:

$url = 'http://example.com/image.php';
$img = '/my/folder/flower.gif';
file_put_contents($img, file_get_contents($url));

Otherwise use Curl:

$ch = curl_init('http://example.com/image.php');
$fp = fopen('/my/folder/flower.gif', 'wb');
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
fclose($fp);

Topic is here.

  • but for example, my question is for example if picked up the image code direct url = "data:image/jpeg;Base64,/9j/4AQSkZJRgABAQEAYABgAD/4QX..." I can make it appear on my page and download, but when passing 10 seconds will be another image and so successively would it be possible to put a variable that will always take this value? date:image..... and so get the value of the next image after 10 seconds of the other...

  • I can’t comment on your question because I don’t have enough reputation, but the address you gave of the image doesn’t work here. Any chance of you saving the image locally on your server? What exactly are you doing?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.