Hello!
I am every interested with this package, but I couldn't modify save option to download file. It is still work as save file.
Any one help me plase?
Thanks in Advance...
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
Hello theavuthnhel,
This is an issue that is really independent of the library. But believe me when I say I understand your frustration in trying to accomplish this. The easiest way to do this is to save the document to a temporary file; open it; and send it to the browser.
Please note; you'll need a separate PHP file that does nothing more than just send the file!
Save the following as Sample_02_TabStops_File.php in the samples folder after you run Example 2.
<?php
// Get FileName from CMS/Framework/Library or temporary variable:
$newDoc = 'results/Sample_02_TabStops.docx';
/* Add our HTTP Headers */
// http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
// http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html
// Doc generated on the fly, may change so do not cache it; mark as public or
// private to be cached.
header('Pragma: no-cache');
// Mark file as already expired for cache; mark with RFC 1123 Date Format up to
// 1 year ahead for caching (ex. Thu, 01 Dec 1994 16:00:00 GMT)
header('Expires: 0');
// Forces cache to re-validate with server
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
// DocX Content Type
header('Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document');
// Tells browser we are sending file
header('Content-Disposition: attachment; filename=Sample_02_TabStops.docx;');
// Tell proxies and gateways method of file transfer
header('Content-Transfer-Encoding: binary');
// Indicates the size to receiving browser
header('Content-Length: '.filesize($newDoc));
// Send the file:
readfile($newDoc);
// Delete the file if you so choose. BE CAREFULE; YOU MAY NEED TO DO THIS
// THROUGH YOUR FRAMEWORK:
//unlink($newDoc);
// End the session. BE CAREFUL; YOU NEED TO DO THIS THROUGH YOUR FRAMEWORK:
session_write_close();
?>
Hope that helps!
Very good @martindavis! Thanks!
Most helpful comment
Hello theavuthnhel,
This is an issue that is really independent of the library. But believe me when I say I understand your frustration in trying to accomplish this. The easiest way to do this is to save the document to a temporary file; open it; and send it to the browser.
Please note; you'll need a separate PHP file that does nothing more than just send the file!
Save the following as
Sample_02_TabStops_File.phpin thesamplesfolder after you run Example 2.Hope that helps!