Page 1 of 1

Downloading Files

Posted: Tue Sep 19, 2006 5:27 pm
by Clukey
I have set up a download page for a user to download a file from my website, but it has stopped working properly (I think because of a new version of IE). Right now I am using application/force-download to download a Dreamweaver Extension (application type: application/x-mmxp). Is there any other way that I could do this to make it a bit more reliable? Thanks

Re: Downloading Files

Posted: Tue Sep 19, 2006 5:38 pm
by arkady
Clukey wrote:I have set up a download page for a user to download a file from my website, but it has stopped working properly (I think because of a new version of IE). Right now I am using application/force-download to download a Dreamweaver Extension (application type: application/x-mmxp). Is there any other way that I could do this to make it a bit more reliable? Thanks
Is the file displaying inline (ie. in your browser)? Or are you getting nothing happening?

Re: Downloading Files

Posted: Tue Sep 19, 2006 5:43 pm
by Clukey
arkady wrote: Is the file displaying inline (ie. in your browser)? Or are you getting nothing happening?
It is displaying inline

Posted: Tue Sep 19, 2006 6:23 pm
by arkady
I've found that the following works fine for myself in both ie & firefox

Code: Select all

header("Pragma: public");
header("Expires: " . gmdate('D, d M Y H:i:s') . " GMT");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private", false);
header("Content-Length: " . $my_filesize);
header("Content-Type: application/" . $file_type[$stated_file_type]);
header("Content-Disposition: attachment; filename='".$filename."'");
header("Content-Transfer-Encoding: binary");  // assuming its a binary file of course
Hopefully this comes in handy for you

Posted: Wed Sep 20, 2006 8:25 pm
by Clukey
Thanks, that works, but is there any way to do this and hide the location of the file?

Posted: Thu Sep 21, 2006 3:37 pm
by feyd
By going through a script you are hiding the location.

Posted: Thu Sep 21, 2006 5:02 pm
by Clukey
Right, but in firefox when it brings up a download file dialog box it shows the relative location to the file.

Posted: Thu Sep 21, 2006 5:32 pm
by feyd
That dialog box is on your local system, not on the server. You can't really hide much from the user, especially when doing stuff over a browser.

Posted: Thu Sep 21, 2006 5:58 pm
by Clukey
Well then is there any way to duplicate the file into another folder temporarily and download it from there?

Posted: Thu Sep 21, 2006 6:06 pm
by feyd
There's no reason to, the path the user sees has no bearing on the file the server is sending, but on what their browser chooses to show them with respect to what your script gives it. I'm not going to repeat this again.