<?php
$str = <<<EOT
呵呵,这里是文件内容。可以吧、!!
真的啊。。。
EOT;
sendFile($str,"测试文件.txt");
function sendFile($serverPath, $filename, $mimeType = 'application/octet-stream')
{
header("Content-Type: {$mimeType}");
$filename = '"' . urlencode($filename) . '"';
header("Content-Disposition: attachment; filename={$filename}");
//readfile($serverPath);
echo $serverPath;
exit;
}
?>