JPG that gets live data from a Webpage
I'm just wondering if there is any way to create a JPG file that loads data from the Web. This would allow me to do things like upload a JPG file that shows live data on a Website where the data I want to show is impossible to show any other way. For example, suppose I want to show a random picture on a Website, but I can only upload one picture at a time. In this case, having one JPG file that tells the computer to load a PHP page that then returns any one picture would be useful.
Re: JPG that gets live data from a Webpage
Just use the a PHP page as the source for the image tag. And then in that PHP page, write the code to pick the random image or whatever image you want to and out it.
Eg:
Code:
<img src="http://www.yoursite.com/somedirectory/generate.php" />
In generate.php file, you would write something like this:
PHP Code:
<?php
$picture = 'mypath/to/image/location/my_image.jpg'; // you can pick an image randomly if needed
$type = 'image/jpeg'; // This is the content type we are going to use. ie, we would be going to tell the browser that that content outputted is of type JPG image, by using the header() function below
header('Content-Type:'.$type); //send the headers to the browser
readfile($picture); // read the file contents and write to the output buffer.
?>
That would be enough. :wave: