Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Storing images in MySQL
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Storing images in MySQL

 Post Reply Post Reply
Author
webbasterd View Drop Down
Groupie
Groupie


Joined: 21 November 2002
Location: Netherlands
Status: Offline
Points: 37
Post Options Post Options   Thanks (0) Thanks(0)   Quote webbasterd Quote  Post ReplyReply Direct Link To This Post Topic: Storing images in MySQL
    Posted: 19 November 2004 at 5:38pm

Hi,

I have a small question regarding storing images in MySQL. I have a classic ASP based website and a MySQL backboned database. In the MySQL database I made a table TblImages to store some images. In order to show a image on the site I use the ASP file image.asp?ID=2 This is the code I used in the image.asp file:

ID=Request("ID")
adoCon.Open strCon
StrSQL = "SELECT * FROM TblImage where Image_ID =" & ID
AdoRec.Open strSQL, AdoCon
Response.ContentType = "image/gif"
Response.BinaryWrite AdoRec("Image")


I also used some code to prevent the ASP files are cached

Response.Expires = -1
Response.ExpiresAbsolute = Now() - 2
Response.AddHeader "pragma","no-cache"
Response.AddHeader "cache-control","private"
Response.CacheControl = "No-Store"
Response.Buffer = True

When I use this the image is not stored in the temp. internet files. This is useful for me because nobody can steel copyrighted images.

What I would like to know is if I use this procedure, will there be a preformance loss in viewing the webpage  or is there no diferance when I use <img src="ImageName.gif"> ? (I use the code to prefent caching on all the ASP pages)

Thanks in advance.

Alexander

Back to Top
dpyers View Drop Down
Senior Member
Senior Member


Joined: 12 May 2003
Status: Offline
Points: 3937
Post Options Post Options   Thanks (0) Thanks(0)   Quote dpyers Quote  Post ReplyReply Direct Link To This Post Posted: 19 November 2004 at 7:25pm

Well, you have to open and read the db for each image, but that's offset by the filessytem opening a regular image. I'd call it a wasy unless your connection to the db is really slow.

This method is useful for preventing hotlinks if you check http_referrer in image.asp to ensure that the request is coming from within your site, but it won't prevent the image from being taken.


Lead me not into temptation... I know the short cut, follow me.
Back to Top
webbasterd View Drop Down
Groupie
Groupie


Joined: 21 November 2002
Location: Netherlands
Status: Offline
Points: 37
Post Options Post Options   Thanks (0) Thanks(0)   Quote webbasterd Quote  Post ReplyReply Direct Link To This Post Posted: 21 November 2004 at 4:47pm

Thanks for the info! I was testing with the http_referrer to prevent hotlinks but some firewalls block reffers. I found a workarround without checking the reffer. On the page where I call the image.asp I fill a session("FromSite") variable. In the image.asp I check if the variable is filled or not......  This works fine :-)

--
Alexander

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.