Shoutbox

Forcing Firefox to show "Save as" dialog, or automaticly start downloading the file? - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Skype & Technology (/forumdisplay.php?fid=9)
+---- Forum: Tech Talk (/forumdisplay.php?fid=17)
+----- Thread: Forcing Firefox to show "Save as" dialog, or automaticly start downloading the file? (/showthread.php?tid=53159)

Forcing Firefox to show "Save as" dialog, or automaticly start downloading the file? by Mike on 11-21-2005 at 07:09 PM

Hello.

I have a text file (with a changed extension) on my webserver.
When I click the link of the file in firefox,  firefox just displays the contents of the text file while IE automaticly opens the file, which is what I actually want to happen...
Or, if I cant do that, show the save as dialog instead of displaying what the file has...

I searched google and i found this: http://www.codecomments.com/PERL_CGI_Beginners/message611929-1.html

Well, as I'm not using Perl, but PHP, I didn't really understand what he did... :-/

Can anyone help me?

I think it has something to do with the headers....

Thanks! :)


RE: Forcing Firefox to show "Save as" dialog, or automaticly start downloading the file? by MeEtc on 11-21-2005 at 07:15 PM

make a link to the file, Right-click, Save link as...


RE: Forcing Firefox to show "Save as" dialog, or automaticly start downloading the file? by Mike on 11-21-2005 at 07:18 PM

quote:
Originally posted by MeEtc
make a link to the file, Right-click, Save link as...
But, I want it to show a save us dialog, and dont have to make the user to do it manually.... :(
RE: Forcing Firefox to show "Save as" dialog, or automaticly start downloading the file? by Stigmata on 11-21-2005 at 07:34 PM

http://www.mozilla.org/support/firefox/options#downloads

file types?

would that work?


RE: Forcing Firefox to show "Save as" dialog, or automaticly start downloading the file? by stoshrocket on 11-21-2005 at 07:35 PM

easiest way i can think of is just saving it into a .zip file then getting them to download it that way, if it is a .txt file it wont take long to download. As for the actual thing that guy did i cant figure it out, but ill keep looking for you, if i find anything ill post it back to you. :)


RE: Forcing Firefox to show "Save as" dialog, or automaticly start downloading the file? by Dempsey on 11-21-2005 at 07:38 PM

you can set the header to force the server to send the file, something like:

code:
header("Content-Type: application/octet-stream");
  header("Content-Disposition: attachment; filename=\"$filename"\");

RE: Forcing Firefox to show "Save as" dialog, or automaticly start downloading the file? by Mike on 11-21-2005 at 07:41 PM

quote:
Originally posted by Stigmata
http://www.mozilla.org/support/firefox/options#downloads

file types?

would that work?
Well, i want to show the save as for all my visitors, not just only me...
quote:
Originally posted by Methos2
easiest way i can think of is just saving it into a .zip file then getting them to download it that way, if it is a .txt file it wont take long to download. As for the actual thing that guy did i cant figure it out, but ill keep looking for you, if i find anything ill post it back to you. :)
Well, its a .pls (winamp playlist) file, fore my internet radio, so I think that it would be boring to have to open the zip to connect to my internet radio...

Thanks for your help anyway :)
RE: RE: Forcing Firefox to show "Save as" dialog, or automaticly start downloading the file? by rav0 on 11-22-2005 at 07:47 AM

Save the file with as something.php, and add this code at the very top:

code:
<?php
header('Content-Type: application/pls+xml');
?>

RE: Forcing Firefox to show "Save as" dialog, or automaticly start downloading the file? by Mike on 11-22-2005 at 01:26 PM

I dont know... :-/
When I put the header, it will ask me if I want to download the php file... :S


RE: RE: Forcing Firefox to show "Save as" dialog, or automaticly start downloading the file? by rav0 on 11-23-2005 at 09:53 AM

quote:
Originally posted by Mike
When I put the header, it will ask me if I want to download the php file... :S

Whose headers, mine or Dempsey's? Dempsey's should ask you if you want to download the file, but not the PHP file, the proper playlist. Mine shouldn't do that at all, assuming settings in the user agent.
RE: Forcing Firefox to show "Save as" dialog, or automaticly start downloading the file? by Mike on 11-23-2005 at 02:29 PM

Dempsey's header were giving me an error.
Your header was asking me if i wanted to download the php file.

Anyway, I saved the pls file as listen.pls.php and added dempsey's code which dt fixed...

I would have used mod_rewrite too, but im getting internal server errors... :(


RE: Forcing Firefox to show "Save as" dialog, or automaticly start downloading the file? by .Roy on 11-23-2005 at 02:34 PM

I suggest you just zip it. Easiest and simplest way to fix this.


RE: RE: Forcing Firefox to show "Save as" dialog, or automaticly start downloading the file? by rav0 on 11-24-2005 at 06:32 AM

quote:
Originally posted by .Roy
I suggest you just zip it. Easiest and simplest way to fix this.

Not really because it needs you to unzip after you have downloaded it, then use the file.

Mike, if my heardes asked you to download the file, then it is because of no or incorrect browser settings.

I have had another idea also. Give the URI of the playlist to the user, and let them have their choice of program open that file directly, rather than having the browser download and then deal with it.
RE: Forcing Firefox to show "Save as" dialog, or automaticly start downloading the file? by Mike on 11-24-2005 at 01:20 PM

Well, as I said in my earlier post, i fixed it by naming the file listen.pls.php and using that header...
It works :)

However, the filename looks abit ugly, because listen.pls.php doesnt sound right... :P