header(Content-disposition:...) question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sejf83
Forum Newbie
Posts: 20
Joined: Fri May 19, 2006 3:53 am

header(Content-disposition:...) question

Post by sejf83 »

Hi,

I'm building an application to force downloads of files from the server using the following function:

Code: Select all

function downloadFile($fileName, $path)
{
   ob_clean();
   header('Content-Description: File Transfer'); 
   header('Content-Type: application/force-download'); 
   header('Content-Length: ' . filesize($path.$fileName)); 				
   header('Content-Disposition: attachment; filename=' . $fileName . '');
   header("Cache-Control: cache, must-revalidate");
   header('Pragma: ');		
   $contents = file_get_contents($path.$fileName);
   echo $contents;
   ob_end_flush();	
}
However, I want the HTML page behind it to change, so that I can display a confirmation message. Is there anyway to do this? It seems the browser stops processing right after it finishes this function.

Thanks.
Post Reply