LoadModule xsendfile_module modules/mod_xsendfile.so
XSendFile On
XSendFilePath O:/phpcode/download # windows平台,驱动器号要大写
<Directory "O:/PHPCODE/DOWNLOAD/">
#XSendFileAllowAbove on #这个在win平台上无效
AllowOverride None
Order allow,deny
</Directory>
php 代码:
<?php
$file = 'O:/phpcode/download/1.zip';
if (!file_exists($file)) {
die("File '$file' doesn't exist.ok");
}
header("Content-Type:application/octet-stream");
header("X-Sendfile: $file");
header('Content-Disposition:p_w_upload;filename=211.zip');
?>