I'm trying to load an image through PHP, but I don't know how.
The filename is stored in the database, such as image.jpg
if($_GET['image']){
// Client requesting image, so retrieve it from DB
$id = mysql_real_escape_string($_GET['image']);
$sql = "SELECT * FROM $tbl_name WHERE id = '$id' LIMIT 1";
}
The client needs to request an image like so
http://example.com/index.php?image=1
And then it should return the image, so it can be embedded like this:
<img src="http://example.com/index.php?image=1" alt="" />
Is this possible?
The imagecreate() function is an inbuilt function in PHP which is used to create a new image. This function returns the blank image of given size. In general imagecreatetruecolor() function is used instead of imagecreate() function because imagecreatetruecolor() function creates high quality images.
$img = 'path/to/image.jpg';
header('Content-Type: image/jpeg');
readfile($img);
just tested it
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With