下载包含$ key数据的文本文件

嘿,所以即时通讯编码一个身份验证,并批量生成密钥时,我希望它们进入文本文件并下载该文本文件,而我尝试过

<?php
    $handle = fopen("file.txt", "w");
    fwrite($handle, "text1.....");
    fclose($handle);

    header('Content-Type: application/octet-stream');
    header('Content-Disposition: attachment; filename='.basename('file.txt'));
    header('Expires: 0');
    header('Cache-Control: must-revalidate');
    header('Pragma: public');
    header('Content-Length: ' . filesize('file.txt'));
    readfile('file.txt');
    exit;
?>

but it also gets the html tags and everything here is picture of that

评论