Reputation: 1384
i am trying to display an image in HTML using:
<img src="/logo.php?seq=5" />
then logo.php looks like:
<?php
$sql="SELECT * from reseller where sequence = '".$_GET["seq"]."' ";
$rs=mysql_query($sql,$conn);
$result=mysql_fetch_array($rs);
echo '<img src="http://www.integradigital.co.uk/customer/'.$result["logo"].'" />';
?>
but its not working - whats the best way to do this so the user seeing the image cannot look at the URL of the image. if they open the image in its own window i want them to see something like http://www.domain.com/logo.php?seq=5 ???
Upvotes: 0
Views: 160
Reputation: 1886
Use readfile()
to read the image in the image.php:
// Read URL from database
$sql = "SELECT * from reseller where sequence = '" . $_GET["seq"] . "'";
$rs = mysql_query($sql,$conn);
$result = mysql_fetch_array($rs);
// Generate path
$path = '/customer/' . $result["logo"];
// Set proper headers
$headers = get_headers( $path );
foreach( $headers as $h )
if( strpos( $h, 'Content-Type:' ) !== false )
header( $h );
// Send file to user
readfile( $path );
Then PHP reads the right logo and outputs it, the user won't be able to see the real path. You can link the logo like you proposed:
<img src="/logo.php?seq=5" alt="Logo">
Upvotes: 2