otuatail Posted September 2, 2016 Share Posted September 2, 2016 I have a HTML 5 page with an embedded PDF document in the same directory. What I want to do is put the PDF in a secure folder with a simple .htaccess. The reason is I don't want anyone to access the pdf document directly. I realise that the document could be downloaded anyway but I just want to log how many times it is looked at using PHP. The HTML document is actually a PHP file. Can this be done as I have made attempts to move it unsuccessfully. Quote Link to comment https://forums.phpfreaks.com/topic/302065-html-5/ Share on other sites More sharing options...
requinix Posted September 2, 2016 Share Posted September 2, 2016 After you put the file someplace not accessible over the web (outside the web root is easiest, otherwise use a .htaccess with appropriate directives to deny access), make a PHP script with <?php /* do whatever you want to log access */ $file = "/path/to/file"; header("Content-Type: application/pdf"); header("Content-Length: " . filesize($file)); readfile($file);and embed the URL to that instead. Quote Link to comment https://forums.phpfreaks.com/topic/302065-html-5/#findComment-1536993 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.