简体   繁体   English

用于存储和检索数据库中的文件(图像)信息以在Web上显示的字段

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

When uploading images through a web application 通过Web应用程序上载图像时

For example: 例如:
Photo Galleries and Photos 照片画廊和照片

I have a Photo table that contains the following properties: 我有一个Photo表,其中包含以下属性:

Id ID
ImageName - image1.jpg ImageName - image1.jpg
ImagePath - uploads/photogallery/photogallery1/image1.jpg ImagePath - 上传/ 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. 我觉得我只需要ImageName,然后通过查看图库并获取图库名称来计算出路径。

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. 如果是,那么您可以将此信息存储在其他位置,例如web.config ,并使用ImageName构建完整路径,您不再需要ImagePath

Else, you can use ImagePath column and drop ImageName . 否则,您可以使用ImagePath列并删除ImageName From there, you can access the image directly. 从那里,您可以直接访问图像。 ImageName can be deduced from ImagePath , by using GetFileName method. 可以使用GetFileName方法从ImagePath推导出ImageName

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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