PHPWord - Select save location

时间:2016-11-26 18:31:17

标签: php file save phpword

I have implemented the PHPWord on my website to generate a template. Everything works fine but there is only one detail. When my file is saved in the site that I choose, a copy is saved in the directory where my php script is located.

Example: I click the generate button and select the desktop to save the file. okay But in the directory where my php "generate.php" is located a copy of the generated file is saved.

--//I type the name of my file.
$nombrearchivo = 'MOP_Implementacion MW_'.$sitene.'_to_'.$sitefe.'_Raylex.docx';

I save my file

$templateWord->saveAs($nombrearchivo);
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header('Content-type: application/vnd.openxmlformats officedocument.wordprocessingml.document');
header('Content-Disposition: attachment; filename="'.$nombrearchivo.'"');
header("Content-Transfer-Encoding: binary ");
echo file_get_contents($nombrearchivo);

1 个答案:

答案 0 :(得分:1)

我得到了解决方案: unlink($filename); // deletes the temporary file