PHP实现文件下载

<?php
    $FilePath = 'abc.txt';
    $file = fopen("php://output", 'w');

Header("Content-type: application/octet-stream"); Header("Accept-Ranges: bytes"); Header("Accept-Length: ".filesize('abc.txt')); Header("Content-Disposition: attachment; filename=".'abc.txt'); echo fread($file, filesize($FilePath)); fclose($file);
原文地址:https://www.cnblogs.com/Skrillex/p/6899369.html