PHP Force Download Causing 0 Byte Files

后端 未结 8 1149
清歌不尽
清歌不尽 2020-12-10 16:11

I\'m trying to force download files from my web server using PHP. I\'m not a pro in PHP but I just can\'t seem to get around the problem of files downloading in 0 bytes in s

8条回答
  •  北荒
    北荒 (楼主)
    2020-12-10 16:54

    i am doing this to download a PDF ...

    $filename = 'Application.pdf';
    header("Content-Type: application/pdf");
    header("Content-Disposition: attachment; filename=$filename");
    echo $pdf;
    

    i think you are missing the last row, where you actually send the file contents of whatever you have in $file.

    Pablo

提交回复
热议问题