Unsaved changes will be lost

Hello,

After downloading a file with readfile, I receive the message “Unsaved changes will be lost” when I quit the application form (control form)

Note: The spreadsheet is correctly created and downloaded.


Here are a few lines from this control form before the lines causing problem
(to give the context)

// Save Excel 2007 file with then name of the calling php filename. test ok
// fichier .xlsx apparaissant à côté du .php
$objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);
$fullpath = str_replace(’.php’, ‘.xlsx’, FILE);
$objWriter->save($fullpath);

$objPHPExcel->disconnectWorksheets();
unset($objWriter, $objPHPExcel);

The problem occurs only when I add the following lines

$file = $fullpath; // changer si on veut un autre nom pour le xls téléchargé

if (file_exists($file)) {
header(‘Content-Description: File Transfer’);
header(‘Content-Type: application/octet-stream’);
header(‘Content-Disposition: attachment; filename=’.basename($file));
header(‘Content-Transfer-Encoding: binary’);
header(‘Expires: 0’);
header(‘Cache-Control: must-revalidate’);
header(‘Pragma: public’);
header('Content-Length: ’ . filesize($file));
ob_clean();
flush();
readfile($file);
exit; // indispensable pour que le fichier excel soit correct
}

Any Idea what is causing the problem ?
Any other method to download a file ?
Is there any documentation on scriptcase error messages ?