2
I have a page that when uploaded sends a pdf file to download. How do I after the file is sent to the browser, redirect the page?
I’m sending the file so do so:
// Dados do arquivo
$file = "Arquivos/documento.pdf";
// Configuramos os headers que serão enviados para o browser
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, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
// Limpa o conteúdo interno do buffer
ob_clean();
flush();
// Envia o arquivo para o cliente
readfile($file);
// Descarrega o conteúdo interno do buffer
ob_end_flush();