I have a php download script that allow user to download a word document file after downloading it is editable to user..i want to make file readonly to user
my code for download is:
//php code
// set headers`enter code here`
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Type: $mtype");
header("Content-Disposition: attachment; filename=\"$asfname\"");
header("Content-Transfer-Encoding: binary");
header("Content-Length: " . $fsize);
// download
// @readfile($file_path);
$file = @fopen($file_path,"rb");
if ($file) {
while(!feof($file)) {
print(fread($file, 1024*8));
flush();
if (connection_status()!=0) {
@fclose($file);
die();
}
}
@fclose($file);
}
thanx in advance Regards
You can't. File attributes aren't sent with the download. The user downloads the file and owns it.
You can password-protect the document, but for that you have to edit it yourself. It is something that can hardly be done by PHP, although you could use the COM interface of Word from PHP on Windows... But that's not a path you want to go.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With