我想在使用php時將輸出文檔保存在服務器上的文件夾中。該代碼將其保存到我的電腦,但我需要將文件保存在名稱的文件夾中。保存輸出文檔在php
請檢查代碼:
// Save File
$h2d_file_uri = tempnam('', 'htd');
$objWriter = PHPWord_IOFactory::createWriter($phpword_object, 'Word2007');
$objWriter->save($h2d_file_uri);
// Download the file:
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename=example.docx');
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($h2d_file_uri));
ob_clean();
flush();
$status = readfile($h2d_file_uri);
unlink($h2d_file_uri);
exit;
我試圖file_put_contents( 'test.txt的',的file_get_contents( 'http://web.com'));但它並沒有幫助我。請告訴我如何將文件保存到文件夾中。