I have a page.php with a form, user click on the button and is redirected to download.php where I have the following code:
$zip_file = substr_replace($url, 'zip', strrpos($url, '.') + 1);
$zip_path = '/dev/' . $zip_file;
header('Content-Type: application/zip');
header('Content-Disposition: attachment; filename="' . $zip_file . '"');
readfile($zip_path);
unlink($zip_file);
header("Location: success.php");
Basically I was very happy because it works very well in local, the download starts and there is the redirect to the success page. When I upload my files on the server, I open page.php, I click on the button and I reach download.php but the download doesn't start, the redirect works, I'm redirected to success.php without any download. If comment the redirect, header(), the download starts, so it's not because of the code (I guess).
My problem is that it's just on the server that the download does not start before redirect, and I have no idea why. I need to remove the redirect to make it work but I can't do that.
I hope someone with more experience could help, thank you very much.
 
     
    