将图像存储在文件夹中 [英] Store images in folder

查看:83
本文介绍了将图像存储在文件夹中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一些用户可以上传多个图像的asp.net网站,以前我将图像存储到数据库中,因此我的数据库大小太大了。即使是Godaddy也只允许200mb的数据库大小。所以我必须选择任何替代解决方案...



有人建议我将图像存储在一个文件夹中并保存其到数据库的路径。在将此应用于我的项目之前,我有一些问题。



我的问题是假设一个用户存储flower.jpg图像然后第二个用户存储不同的文件但是同名flower.jpg,将第一个图像替换为第二个一?或两个图像都将存储。如果两个图像都以相同的名称存储,那么我如何识别哪个用户上传的图像。



后来我必须在转发器控件和aspx页面中检索这些图像,我认为它不会在retreiving时产生任何问题。将图像存储在文件夹中有任何缺点。

给出您的意见。

I am working on some asp.net website in which users can upload multiple images, Previously i am storing images to database and so that my database size is going too large. Even Godaddy is allow only 200mb database size. So i have to choose any alternative solution...

someone suggests me to store images in a folder and save its path to the database. Before apply this to my project i have some questions.

My question is suppose one user store flower.jpg image and then second user storing different file but with same name flower.jpg, will the first image is replace by second one? or both images will store. If both image will store with same name then how can i recognize which image is upload by which user.

Later on i have to retreive these images on repeater control and in aspx page, i think it will not create any problem while retreiving. Is any drawback for storing images in a folder.
Give your opinion.

推荐答案

您是否可以在路径名中包含用户唯一ID保存图像?

即image-path-name +/+ user-id +/+ flower.jpg
Could you include a users unique id in the pathname when saving the images?
i.e. image-path-name + "/" + user-id + "/" + flower.jpg


引用:

假设一个用户存储flower.jpg图像,然后第二个用户存储不同的文件但名称为flower.jpg,第一个图像会被第二个图像替换吗?

Suppose one user store flower.jpg image and then second user storing different file but with same name flower.jpg, will the first image is replace by second one?



可能。但是,你可以将它存储给不同的用户。

示例:(对于user1)图像将存储在路径Images \Users\User1

(对于user2) )图像将存储在路径Images \Users\User2

或类似的东西中..




Possible. But, you can store it for different user.
Example: (for user1) The images will be stored in the path Images\Users\User1
(for user2) The images will be stored in the path Images\Users\User2
or something like that..

引用:

如果两个图像都存储相同的名称,那么我如何识别哪个用户上传的图像。

If both image will store with same name then how can i recognize which image is upload by which user.



这是您设计数据库的方式,以便您找到它。主键有助于我思考。


It is how you design your database for you to find it out. Primary key will help I think.


使用GUID是不覆盖图像的好方法。

http://www.webcodeexpert.com/2014/03/how-to-uploadsave-image-in-folder- and.html [ ^ ]
use of GUID is good solution for not overwriting the images.
http://www.webcodeexpert.com/2014/03/how-to-uploadsave-image-in-folder-and.html[^]


这篇关于将图像存储在文件夹中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆