开发者

yii: serve a file when logged in

开发者 https://www.devze.com 2023-04-01 03:05 出处:网络
I have pdf files in a htaccess-protected directory that I want to show to some users in Yii application.

I have pdf files in a htaccess-protected directory that I want to show to some users in Yii application.

How is best to solve that? I understand it should be done inside Yii, not w开发者_如何学Cith a separate script as it needs to check if a valid user is logged in.


Access control filters


You would do your appropriate security checking (user is in group, or has permission or whatever) and then you would use readfile or something similar.

Do you have code already that isn't working? Or did you just need help with what approach to take?


Thanks!

I got some idea from this link:

http://harrybailey.com/2011/07/yii-rewrite-files-or-images-for-download-or-display/

In short: made a new actionfunction into controller and in that function sending headers and readfile.

0

精彩评论

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