Pregunta

I'm using PhpWord to save some data in Word format. The thing is that I need the user to select the place where it's needed to be saved. Right now I set it in the following way:

$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
$docName = '../../../files/generated_documents/document.docx';
$objWriter->save($docName);

Is there any way to make the user select the location to store the document?

¿Fue útil?

Solución

I finally find the answer. It is possible if the document is stored in the server side end then you make the action of allowing the user to download it. The following code explain it:

$docName = 'document.doc';
$docPath = 'path/inThe/server/';
$fullName= $docPath.$docName;
$objWriter->save($fullName);
$this->downloadTimeSheetFile($docName,$docPath);


header('Content-type: application/doc');
header('Content-Disposition: attachment; filename="'.$docName.'"');
readfile($fullName);

Hope somebody can use it! :)

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top