0

I am newbie with PHP and backend

below codes send a file to client

$size = strlen($data);
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename={$name}");
header("Content-Length: $size");
if (isset($_SERVER['HTTPS'])) {
    header('Pragma: ');
    header('Cache-Control: ');
} else {
    header("Pragma: private");
    header("Cache-Control: private, must-revalidate");
}

here I want to reload page after download file

I've tried below code But it didn't work

header('Refresh: 0;');

so How can I reload/refresh page after download finished ?

morteza mortezaie
  • 1,002
  • 14
  • 37
  • 1
    You cannot do it that way. This simply is not possible by a purely server side solution. You have two options: both require client side logic: 1. download the file by an extra request done via ajax, triggered by the client side. When that request is done the client can decide to refresh the still loaded page. 2. refresh the loaded page blindly after a certain period of time, this also has to be triggered by a client side logic. – arkascha Jul 02 '23 at 14:19
  • Does this answer your question? [Refresh a page using PHP](https://stackoverflow.com/questions/12383371/refresh-a-page-using-php) – doneforaiur Jul 04 '23 at 16:20
  • no , sorry it is not – morteza mortezaie Jul 05 '23 at 09:51

0 Answers0