图像上传服务 - 图像位置和图像标识符
我想创建一个图像上传服务(是的,我知道 imageshack、photobucket、flickr...等):)
我只看到 imageshack 显示图像所在的目录名称(“img294”、“1646”)位于,以同样的方式 - 我想这样做。
http://img294.imageshack.us/img294/1646 /**jquerykd5**.jpg
1) 如果我采用此实现,是否存在我应该注意的安全问题?
2) 这些网站如何提供简短的唯一标识符(“kd5”)?
感谢大家的建议和帮助。
I would like to create a image uploading service (yes, i am aware of imageshack, photobucket, flickr...etc) :)
I have seen only imageshack show the directory names ("img294", "1646") of where the image is located, in the same way - i would like to do this.
http://img294.imageshack.us/img294/1646/**jquerykd5**.jpg
1) Are there any security issues I should be aware if i take this implementation?
2) How do these sites come up with short unique identifiers ("kd5")?
Thanks all for any advice and help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对于初学者来说,除非您希望该目录是公共的,否则请将虚拟的 index.html 文件放在那里,或者只是限制公共用户对这些目录的访问。
至于唯一标识符,有很多方法可以解决这个问题...我最喜欢使用的一些信息块:
有了这些信息和许多其他信息,应该很容易防止重复的图像名称在服务器上发生冲突,您可以收集任意数量的图像并将它们连接成文件名的字符串。 md5 也可以放置在数据库中,以帮助重复图像检测方法,这也可以节省磁盘空间。
Well for starters, unless you would like the directory to be public, put dummy index.html files in there or just restrict access to public users for those directories.
As for the unique identifiers there are many ways of going about this... some of my favourite chunks of information to use:
With these and many other pieces of information at your fingertips it should be easy to prevent duplicate image names conflicting on your server as well, you can gather as many as you like and concatenate them into a string for the filename. The md5 can be placed in a database as well to aid in a method of duplicate image detection, which could save you disk space as well.
我可以向你保证他们都使用URL重写。 这也将有助于解决安全问题。
I can promise you they all use URL rewriting. This will help with security issues, too.