Forum


Replies: 6   Views: 3679
Template, saves curropt file.
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by fortech  · 11-04-2013 - 12:12

Changing the corrupted doc file I get:
<br />
<b>Warning</b>: readfile(test.docx) [<a href='function.readfile'>function.readfile</a>]: failed to open stream: No such file or directory in <b>**root**/phpdocx/classes/CreateDocx.inc</b> on line <b>2432</b><br />

relating to:

public function createDocxAndDownload()
{
$args = func_get_args();

try {
$this->createDocx($args[0], $args[1]);
}
catch (Exception $e) {
self::$log->fatal($e->getMessage());
exit();
}

if (!empty($args[0])) {
$file_parts = explode("/", $args[0]);
$fileName = end($file_parts);
} else {
$fileName = 'document';
}

self::$log->info(
'Download file ' . $fileName . '.' . $this->_extension . '.'
);
header(
'Content-Type: application/vnd.openxmlformats-officedocument.' .
'wordprocessingml.document'
);
header(
'Content-Disposition: attachment; filename="' . $fileName .
'.' . $this->_extension . '"'
);
header('Content-Transfer-Encoding: binary');
readfile($fileName . '.' . $this->_extension); // <---- this line
}