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を'))試してみました。それは私を助けなかった。ファイルをフォルダに保存する方法を教えてください。