Re: postgres-embedded images via php. two issues...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 2004-11-03 at 10:20 +1000, Tom Rogers wrote:
> Hi,
> 
> Wednesday, November 3, 2004, 8:45:17 AM, you wrote:
> PG> i am storing images in a postgres database and i have set up a little 
> PG> php file to retrieve them in such a way that i can do:
> 
> PG> echo "<img src='gif.php?name=$picname'>";
> 
> PG> ...from another php file.
> 
> PG> it's working great, BUT i've noticed two things that bother me:
> 
> PG> [1]  if someone wants to download an image, they can, but it will be 
> PG> downloaded as "gif.php" instead of "whatever.gif".  even though 
> PG> renaming the file solves the problem, users will be confused by this.
> 
> 
> It does not matter what the extension is, it is the header that has more sway
> 
> 
> PG> [2]  (and i think this may be related to the first problem) is that in 
> PG> at least one of my browsers (camino/osx) the images are ALWAYS pulled 
> PG> directly from the server.  they are never cached by the browser.  i 
> PG> suppose all browsers may be behaving this way, but in camino, it is 
> PG> blatantly and visually obvious as you watch the gif being slowly 
> PG> downloaded/displayed over a slow connection.
> 
> The browser wont cache url's that have the ? in them so change your info passing
> scheme to echo "<img src='gif.php/name=$picname'>";
> then process the query string to extract the info
> 
> You could even add a dummy value at the end like
> src='gif.php/name=$picname/type.gif to make it look like a gif'
> 

In my .htaccess file, I have placed the following :

RewriteEngine On
RewriteRule ^images/([0-9]+)$ image.php?id=$1 [L]
RewriteRule ^images/(.*)$ image.php?filename=$1 [L]

This allows either: http://localhost/images/5 or
http://localhost/images/myimage.png to work. I prefer the filename as it
looks cleaner and appears to be more standard. So, in a webpage, I can
now add the following html code to show the image.

<img src="http://localhost/images/myimage.png"; />

-- 
/***************************************
* Robby Russell | Owner.Developer.Geek
* PLANET ARGON  | www.planetargon.com
* Portland, OR  | robby@xxxxxxxxxxxxxxx
* 503.351.4730  | blog.planetargon.com
* PHP/PostgreSQL Hosting & Development
*    --- Now supporting PHP5 ---
****************************************/

Attachment: signature.asc
Description: This is a digitally signed message part


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux