简体   繁体   中英

Fields for storing and retrieving file (image) information from database to display on web

When uploading images through a web application

For example:
Photo Galleries and Photos

I have a Photo table that contains the following properties:

Id
ImageName - image1.jpg
ImagePath - uploads/photogallery/photogallery1/image1.jpg
Description - this will most likely be the title and alt text

My goal is to be able to save the proper information that will make retrieval of these photos very easy. Do I even need those fields? I feel like I simply just need the ImageName and then can figure the path out by looking up the gallery and getting the gallery name.

Any suggestions?

Is your gallery restricted only to one folder?

If yes, then you can store this information somewhere else, such as web.config , and use ImageName to construct the full path, you do not need ImagePath anymore.

Else, you can use ImagePath column and drop ImageName . From there, you can access the image directly. ImageName can be deduced from ImagePath , by using GetFileName method.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM