2011年6月24日 星期五

header輸出檔案錯誤

今天在試一個輸出檔案的錯誤,
下載pdf是ok的,但word就會有問題,
查了半天,
原來是因為在header出來前,
就先用echo輸出資料,
寫入了word的標頭,造成錯誤…
又花了半小時查錯誤,
之前就已經錯過了,也花了好幾個小時找錯誤…
我真該撞牆~~~


//echo $file ;  <<就是錯在這,笨!

header("Content-Type: application/force-download");
header('Content-Disposition: attachment; filename='.$file_name); 
header("Content-Transfer-Encoding: binary");
readfile($file_path); 
exit ;

沒有留言:

張貼留言