gpt4 book ai didi

php - php word文档代码只读

转载 作者:行者123 更新时间:2023-12-04 03:09:54 25 4
gpt4 key购买 nike

我有一个 php 下载脚本,允许用户在下载后下载一个 word 文档文件,它对用户是可编辑的..我想让文件对用户只读

我的下载代码是:

//php代码

// 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);
}

提前谢谢问候

最佳答案

你不能。文件属性不会随下载一起发送。用户下载文件并拥有它。

您可以用密码保护文档,但您必须自己编辑它。这是 PHP 很难做到的事情,虽然您可以在 Windows 上使用 Word 的 COM 接口(interface)从 PHP 中...但这不是您想要走的路。

关于php - php word文档代码只读,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7370843/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com