I'm trying to generate a .html file and download it.
My issue: First i check if file exists, if true i delete it and create a new one.
When i click to generate file, the downloaded file is always the first file created and isnt updated. I've checked the file manualy and its ok but the downloaded is the old one. If i delete the file on server i can download anyway.
check the site: bit.ly/1crrcif
$content = "<html></head></head><body>All content here</body></html>";
if( empty( $error )){
echo "<h3>File generated</h3>";
$my_file = 'change_nameto_index.html';
if (file_exists($my_file)) {
echo "file exists";
unlink($my_file);
}
$new_file = 'change_nameto_index.html';
$handle = fopen($new_file, 'w') or die('Cannot open file: '.$new_file);
$data = $content;
fwrite($handle, $data);
fclose($handle);
echo "<a download='change_nameto_index.html' href='change_nameto_index.html'>"
. "<b class='download'>Download</b></a>"
;