我想在使用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'));但它并没有帮助我。请告诉我如何将文件保存到文件夹中。