PHP to protect PDF and DOC

后端 未结 4 452
名媛妹妹
名媛妹妹 2021-01-01 03:10

I am trying to provide .pdf and .doc files to authorized users on a website. The user can only see the file selection page when logged in but this

4条回答
  •  天涯浪人
    2021-01-01 03:51

    This did the job for me: I placed a .pdf and a .htaccess file with the following code in it in a normal folder (i named it "docs") on my apache webserver.

    Order Deny,Allow
    Deny from all
    Allow from 127.0.0.1
    
    
        Order Allow,Deny
        Allow from all
    
    

    Then i took the code from Martin Barkers answer above, changed the filepath to "docs/sample.pdf", and pasted it into a .php file in my root directory. That's it. You can't access the file per url now, but you can download it if you run test.php.

提交回复
热议问题