<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
}