Jump to content

Recommended Posts

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. 

Link to comment
https://forums.phpfreaks.com/topic/302065-html-5/
Share on other sites

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.
Link to comment
https://forums.phpfreaks.com/topic/302065-html-5/#findComment-1536993
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.