开发者

Protecting Photo Folder

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 开发者_如何学Pythona 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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜