im having a problem in resizing an image on the Fly and i just need to know is there anything wrong with that line

<img src="image_resize.php?image=<?=$arr?>&max_width=200&max_height=120">

Recommended Answers

All 2 Replies

hello,,
In img tag, the src is to have an image source like mylogo.gif etc...you can't pass an php page name..if you want to make that image clickable then,put it in to anchor tag or put onClick method on that image tag....
or
write your line like this way:

<a href="image_resize.php?image=<?=$arr['picture']?>&max_width=200&max_height=120"><img src="<?=$arr['picture']?>" width="200" height="120"> </a>

check it all.
thank you...

That depends on what you are doing though. You can make the src = a php file if on that file you are sending the image to the browser kind of like this.

<?
$imagedata = file_get_contents("temp/" . $randstring . ".jpg");
header('Content-type: image/jpg');
echo $imagedata;
exit();
?>

If you are doing something like that, then this should work. On this page I pull the file from a postgres database and save it to a temporary location for processing. Read the data with file_get_contents and send it to the browser with the header "Content-type: image/jpg". the browser will read it just like any other image.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.