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;
}
어떻게해야 같은 코드 모양이없이 : "$ FH =하면 fopen ($ 파일, 'w');에 fwrite ($ FH, $ StringData가) FCLOSE ($ fh); " 및이 "unlink ($ file);"
은 내가 다음의 내용을 출력 헤더에 여기