I want to unlink a file once the readfile() is finished
require_once 'PHPWord.php';
$PHPWord = new PHPWord();
$section = $PHPWord->createSection();
$wordText = utf8_encode($_REQUEST['TEXT']);
$section->addText($wordText);
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
//$objWriter->save('helloWorld.docx');
$name = microtime();
$path = 'tmp/Services.docx';
$objWriter->save($path);
$essai = 'php/'.$path;
echo $essai;
readfile($objWriter);
unlink($path);
exit;
The point is the file is unlinked before it's read ! I mean that when I launch my download I have a beautiful 404 not found. If I remove the unlink my download is working fine
Here is what I do in javascript side, it's ExtJs :
Ext.Ajax.request({
url: 'php/treeWord.php',
method: 'POST',
params: {
'TEXT' : arrString
},
success : function(r){
var javaScriptVar = r.responseText;
alert (javaScriptVar);
window.open(javaScriptVar);
}
});