簡體   English   中英

readfile下載損壞的文件

[英]readfile downloads corrupt files

當我嘗試從本地主機下載某個文件時遇到問題。 每次下載文件時,無論是.docx,.pdf還是.png,它總是損壞的。 我花了多個小時來尋找解決方案,但似乎沒有任何效果。

這是我正在運行的腳本:

$file_download="loonadministratie/{$loon_id}/{$file}";
        if (file_exists($file_download)) {
                header('Content-Description: File Transfer');
                header("Content-Type: application/octet-stream/loonadministratie/{$loon_id}/");
                header('Content-Disposition: attachment; filename='.basename($file_download));
                header('Expires: 0');
                header('Cache-Control: must-revalidate');
                header('Pragma: public');
                header('Content-Length: ' . filesize($file_download));
                readfile($file_download);
                exit;
            }

正手感謝

嘗試

<?php
if (ob_get_level()) ob_end_clean();
?>

可能是問題

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM