1
或者用戶可能下載文件而不保存在服務器上? 我正在從數據庫獲取數據,並且想要保存它們.doc(MS Word)文件。下載文件,而不保存在服務器中
if(isset($_POST['save']))
{
$file = "new_file2.doc";
$stringData = "Text text text text...."; //This data put in new Word file
$fh = fopen($file, 'w');
fwrite($fh, $stringData);
fclose($fh);
header('Content-Description: File Transfer');
header('Content-type: application/msword');
header('Content-Disposition: attachment; filename="'.$file.'"');
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
ob_clean();
flush();
readfile($file);
unlink($file);
exit;
}
應該如何代碼看起來像沒有這個: 「$跳頻=的fopen($文件, 'W');
的fwrite($跳頻,$ StringData是); FCLOSE( $ FH);」 和這個「取消鏈接($文件);」
我希望能理解我需要什麼 這裏