強制下載 application/force-download, 將傳送 HTTP 標頭您的瀏覽器並告訴它下載,而不是在瀏覽器中執行的檔案
$content_url//下載檔案地址, 可以是網際網路地址, 也可以是本地物理路徑或者虛擬路徑
ob_end_clean(); //函式 ob_end_clean 會清除緩衝區的內容,並將緩衝區關閉,但不會輸出內容。
header(“Content-Type: application/force-download;”); //告訴瀏覽器強制下載
header(“Content-Transfer-Encoding: binary”);
header(“Content-Length: $taille”);
header(“Content-Disposition: attachment; filename=” 下載後的名字以及字尾”);
header(“Expires: 0”);
header(“Cache-control: private”);
header(“Pragma: no-cache”); //不 WordPress 加速快取頁面
readfile($content_url);