如何在fileupload控件中保存两个具有相同名称的相同图像。 [英] How to save two same image with same name in fileupload control.

查看:78
本文介绍了如何在fileupload控件中保存两个具有相同名称的相同图像。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望在我的页面中有一个文件上传控件,当一个人上传图像时,它会转到根目录中的图像文件夹,我的问题是当一个人上传一个名字像arpit.jpg的图像,之后有时候另一个人会上传一个同名的图像然后我们如何区分这两个用同名上传的图像。

i want a file upload control in my page in which when a person upload a image than it will go to image folder in root directory, my question is that when a person upload a image with name like arpit.jpg, and after some time another person will upload a image with same name then how we can differenciate between these two images which are uploaded with same name.

推荐答案

你需要考虑一些约定。对于例如添加带有日期时间戳的前缀/后缀,上传文件的用户的名称等。



请查看以下链接,了解如何执行此操作:



http://stackoverflow.com/ questions / 2621535 / how-to-change-fileupload-name [ ^ ]
You need to consider some kind of convention. For e.g. add a prefix/suffix with a datetime stamp, the name of the user who uploaded the file etc.

Look at the link below on how to do that:

http://stackoverflow.com/questions/2621535/how-to-change-fileupload-name[^]


与其他任何系统相同的方式:

1)附加版本号在文件扩展名之前(如果它是同一个用户)

2)将其存储在不同的文件夹中(如果它是不同的用户),这样用户只能看到自己的文件。

3)使用临时文件名存储它,并使用数据库将临时名称与真实名称交叉关联。



我使用GUID值作为存储文件名的第一个和最后一个方法以及使用GUID作为行索引的简单SQL表。
The same way you would do it for any other system:
1) Attach a version number before the file extension (if it's the same user)
2) Store it in a different folder (if it's a different user) so users only see their own files.
3) Store it using a temporary file name, and use a database to cross-correlate the temporary name to the "real" name.

I use both the first and last methods with GUID values as the stored file name and a simple SQL Table using the GUID as the row index.


这篇关于如何在fileupload控件中保存两个具有相同名称的相同图像。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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