PHP文件下载

/**
 * @param string $file_address 文件路径
 * @param string $old_file_name 下载文件命名
*/
$file = fopen ( $file_address, "rb" );//打开文件
Header ( "Content-type: application/octet-stream" );
Header ( "Accept-Ranges: bytes" );
Header ( "Accept-Length: " . filesize ( $file_address ) );
Header ( "Content-Disposition: attachment; filename=" . $old_file_name );
echo fread ( $file, filesize ( $file_address ) );
fclose ( $file );
exit ();

 

你可能感兴趣的:(实用小技巧)