Only allow access of FIle From embed
So I am embedding a PDF file on my page:
<embed src="http://www.mywebsite.com/file开发者_开发技巧s/ebook.pdf" width="500" height="375">
Is there anyway to prevent any and all access to that file except for when it is being accessed via this embed?
Thanks!
More elegant way would be to prevent access to that file or better directory from .htaccess file and only allow locally. Then your php script will acss the file when you need it. You can also force download from php.
See this for php example.
And your .htaccess file will look like this and will reside in your restricted directory (where pdf is located):
#denies access to all but the allowed IP (presumably yours)
#all other users will be redirected to the ErrorDocument
ErrorDocument 403 http://www.example.com/your-login-page.php
Order deny,allow
Deny from all
Allow from 76.117.227.192
Last line is your IP address (server) or put simply Allow from localhost
instead. If somebody else will try to access the directory or files in it, they will be redirected to ttp://www.example.com/your-login-page.php
with status code 403
(access forbidden). Good Luck
you can use something can this from flashpaper from adobe http://www.adobe.com/products/flashpaper/ that way you can show your pdf files as flash embeddable but users cannot download it
精彩评论