문제

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?

도움이 되었습니까?

해결책

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! :)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top