保护照片文件夹
我想开始保护我的照片文件夹,这些照片正在出售,我想阻止人们通过 URL 访问这些照片,而且我位于 Windows 服务器上。照片文件夹只能由网站脚本使用/查看。
我在一些地方读到,我可以将受保护的目录存储在“www”文件夹之前,因此不可能直接链接...所以...
我的服务器结构是这样的:
C:home/m/y/mySite/
在这个目录(mySite)中,有其他三个目录:
/logs
/private
/www
1)是否可以将我的照片文件夹放在私人文件夹中?这样会安全吗?我的脚本和图像标签可以从此位置加载图像吗?
2)如果是,我无法理解“IMG SRC”是什么,因为您不能在 src 中使用驱动器号(C:)。例如, 显然不起作用。这怎么可能……或者我该如何解决这个问题?
任何想法或经历都感激不尽。
I would like to start protecting my photos folder, the photos are for sale and I would like to stop people accessing the photos by URL and I'm on a Windows server. The photos folder should only be used/seen by the website scripts.
I have read in a few places that I can store my protected directory before the 'www' folder, so direct linking is not possible... so...
My server structure is like this:
C:home/m/y/mySite/
In this directory (mySite), there are three other directories:
/logs
/private
/www
1) Is it possible to put my photos folder in the private folder? Is this going to be safe? Can my scripts and image tags load images from this location?
2) If yes, I can't understand what the 'IMG SRC' would be, as you cannot use drive letters (C:) in the src. For example, <img src="c:home/m/y/mySite/private...">
will not work apparently. How is this possible... or how do I get round this?
Any thoughts or experiences gratefully received.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,您走在正确的道路上。
要使其工作,您可以做的是编写一个页面,从私有目录中获取文件内容。您可以制作类似 http://www.example.com/photos/12345 的内容。当用户访问该链接时,脚本会进行检查以确保他们已登录并拥有该照片的权限。如果是这样,它会获取文件内容并将其包含在页面中,而不是通常的 HTML 输出。
在发送实际图像文件数据之前,您需要发送与要发送的图像类型对应的 MIME 标头。
Yes, you are on the right track.
What you can do to make it work is program a page that gets the file contents from the private directory. You could make something like http://www.example.com/photos/12345 . When the user accesses that link, the script checks to make sure they are logged in and have authority for that photo. If so, it fetches the file contents and includes it in the page instead of the usual HTML output.
You will need to send a MIME header for the type of image you are sending before you send the actual image file data.