I’m currently working with cakephp and I am generating a word document. My problem is how can I put the generated document on my web root and not as a download.
I’m currently working with cakephp and I am generating a word document. My problem
Share
I am guessing you are using an action to generate a document, which gets output to the browser.
You should either use output buffering to “catch” the output and then write it to a file, or write the document data to a string, and write that string to a file on the server.
EDIT:
PHPWord has a SAVE method. In your action, you can save the document to a certain location, but output something else, i.e. success notification. This way, your action only generates the file:
If you want to protect that file, you could save the file to a “secure” folder (this can either be a folder outside the “app/webroot” folder, or a folder protected with .htaccess deny all instruction) and than use another action, like “getWordDocument”:
Please note, that this code is just for “grasping the concept” and is in no way safe or optimal.