Forums
This topic is locked
Calling images from Database
Posted 02 Apr 2003 06:53:26
1
has voted
02 Apr 2003 06:53:26 Greg LeBreck posted:
Another one from me. You guys are so helpful I'll just keep asking.Alright.. In ASP with an Access database.
I have set up the backend of the website so I can upload images to a database. The actuual image is stored in a folder and the info for it in the database. I use those images to be displayed on different parts of the website. How would I be able to set it up so I could upload the image and it does not have to have the same file name as the old one and it still gets displayed in the same place? Also I would like to be able to delete the old file while uploading the new image.
Thanks
Replies
Replied 02 Apr 2003 08:38:36
02 Apr 2003 08:38:36 Vince Baker replied:
You need to place a dynamic image source...
Create a recordset on the page that will show the table that contains the filename.
Select 'insert image' and instead of browsing for the image you want to click on data sources at the top of the window.
Now, select the field from the recordset that contains the filename for the image to be displayed.
At the bottom of the window you will now see the code for the recordset field in the 'url' box. Add the path to the folder that the uploads are stored in before the code (e.g. /site/uploadedfiles/<%=.......)
and there you have your dynamic image.
Regards
Vince
Visit my home: www.chez-vince.com
VBScript | ASP | HTML | SQL | Oracle | Hosting
Create a recordset on the page that will show the table that contains the filename.
Select 'insert image' and instead of browsing for the image you want to click on data sources at the top of the window.
Now, select the field from the recordset that contains the filename for the image to be displayed.
At the bottom of the window you will now see the code for the recordset field in the 'url' box. Add the path to the folder that the uploads are stored in before the code (e.g. /site/uploadedfiles/<%=.......)
and there you have your dynamic image.
Regards
Vince
Visit my home: www.chez-vince.com
VBScript | ASP | HTML | SQL | Oracle | Hosting
Replied 02 Apr 2003 17:43:33
02 Apr 2003 17:43:33 Greg LeBreck replied:
Ok that worked if there is only one image in the database. What if there are several. How do I get it to pick the one I want? My DB fields are.. image_id, image_name, image_location.
Replied 02 Apr 2003 18:25:13
02 Apr 2003 18:25:13 Brent Colflesh replied:
Hopefully you have a unique index in your table - then you can a single display page & feed it the unique ID as a variable to pick which record to display.
Regards,
Brent
Regards,
Brent
Replied 02 Apr 2003 18:31:56
02 Apr 2003 18:31:56 Greg LeBreck replied:
Ok here are the fields image_id, image_name, image_location. The unique key is image_id. The recordset contains all 3. What I ned to know is how to set it up so the image when pulled from the datasource(image_location) is = to a unique key (image_id)
Replied 02 Apr 2003 20:32:58
02 Apr 2003 20:32:58 Brent Colflesh replied:
Sorry - you've lost me...
<img src=../images/dmxzone/forum/icon_smile_sad.gif border=0 align=middle>
Regards,
Brent
<img src=../images/dmxzone/forum/icon_smile_sad.gif border=0 align=middle>
Regards,
Brent
Replied 02 Apr 2003 20:35:42
02 Apr 2003 20:35:42 Greg LeBreck replied:
I got it! The name is specific to the picture. So what I did was create a filtered recordset. And it all worked!