2011-09-10 58 views
1

我有一個PHP下載腳本,允許用戶下載一個Word文檔文件下載是可編輯的,以user..i想使文件只讀到用戶後碼只讀

我下載的代碼是:

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

thanx提前 問候

回答

2

你不能。文件屬性不會隨下載一起發送。用戶下載文件並擁有它。

您可以密碼保護文檔,但爲此您必須自己編輯它。儘管你可以在Windows上使用PHP的Word的COM接口,但這是PHP很難做到的事......但這不是你想要的路徑。

+0

我使用linux平臺 – ahmer

+0

好吧,那不是一個選項。但這些Word文檔是在某處創建的。創建它們的人可以設置密碼,甚至可以將它們存儲爲pdf,這在最新版本的Office中是可行的。 – GolezTrol

2

如果您想要只讀文檔,爲什麼不使用pdf呢?