Download leavin a blank screen

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
hame22
Forum Contributor
Posts: 214
Joined: Wed May 11, 2005 5:50 am

Download leavin a blank screen

Post by hame22 »

Hi

I have set up a script to download a pdf file:

Code: Select all

$size = filesize($path);
		$file = basename($path);
		
		header ("Content-Type: application/octet-stream");
		header ("Content-Type: application/download");
		header("Content-Disposition: attachment; filename=$file");
		header("Content-Length: $size");
		readfile($path);
It works fine but when used in mozilla and some versions of explorer i get a blank browser left after it has been downloaded, is there anything i can do to remove this?

thanks
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Apart from not opening the download in a popup then you could use JS to automatically close the window... the problem being that you need to work out when the download is complete. It's the default behaviour for Mozilla FF.
hame22
Forum Contributor
Posts: 214
Joined: Wed May 11, 2005 5:50 am

Post by hame22 »

how could i go about not opening this download in a pop up?

I realy want to remove this blank screen as my users do not like it

thanks
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

hame22 wrote:how could i go about not opening this download in a pop up?

I realy want to remove this blank screen as my users do not like it

thanks
Sorry I was assuming you were doing something like

Code: Select all

<a href="?download" target="_blank">Click to download</a>
Which forces the download to open in a new window. In IE that closes as soon as the download dialog appears. In FF however it remains open. How are you initiatiing the download on the client side? I've not seen the blanks screen in FF other than when using popup windows.
hame22
Forum Contributor
Posts: 214
Joined: Wed May 11, 2005 5:50 am

Post by hame22 »

that is how I am doing it, is there a better way to do this?

thanks for your help
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Just leave out the target="" attribute. The window location will not change but the save dialog box will open ;)
hame22
Forum Contributor
Posts: 214
Joined: Wed May 11, 2005 5:50 am

Post by hame22 »

haha, lovely jubbly
Post Reply