Yii Framework Forum: How To Access Photos Under Yii Protected Directory? - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

How To Access Photos Under Yii Protected Directory? Rate Topic: -----

#1 User is offline   manhooei 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 34
  • Joined: 13-September 11

Posted 26 May 2013 - 01:38 PM

I created a directory under my protected directory in yii and placed all my photos there.
I don't want anyone be able to access those photos directly. How can I set the path to those
photos in my htm img src ? Is there a basePath for the protected ?
0

#2 User is offline   mikewalen 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 41
  • Joined: 27-August 11
  • Location:Hamilton, New Zealand

Posted 27 May 2013 - 03:51 AM

Hey manhooei,

I needed to do this a few weeks ago and after hours and hours of searching for the best way, I went with the hotlinking prevention option using your webserver's .htaccess file (Apache) or the web.config file (IIS).

The trouble with wanting to put your images under the protected folder is you won't be able to access them at all from a url, which is what is required for an img src attribute (not a server path as you were hoping). As soon as you allow an alias to a folder in your protected directory, all of the files are accessible and you're no better off for storing them there.

Just do a google search for 'hotlinking prevention' and you'll find some resources for protecting your images from direct access.
1

#3 User is offline   manhooei 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 34
  • Joined: 13-September 11

Posted 27 May 2013 - 10:53 AM

View Postmikewalen, on 27 May 2013 - 03:51 AM, said:

Hey manhooei,

I needed to do this a few weeks ago and after hours and hours of searching for the best way, I went with the hotlinking prevention option using your webserver's .htaccess file (Apache) or the web.config file (IIS).

The trouble with wanting to put your images under the protected folder is you won't be able to access them at all from a url, which is what is required for an img src attribute (not a server path as you were hoping). As soon as you allow an alias to a folder in your protected directory, all of the files are accessible and you're no better off for storing them there.

Just do a google search for 'hotlinking prevention' and you'll find some resources for protecting your images from direct access.


Yes I figured that out. I actually moved them out and use .htaccess file to deal with them. Thanks!
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users