Re: Force download WITHOUT readfile?

From: Tim Van Wassenhove (euki_at_pi.be)
Date: 06/09/04


Date: 9 Jun 2004 16:26:04 GMT

In article <1e963607.0406090810.221327e3@posting.google.com>, Matthew Sims wrote:
> Is it possible to force a download without using the readfile
> function?

You tell me, is there another way than a UserAgent that downloads file(s)?

> My website setup consists of my server that serves the web pages plus
> a high-speed file server elsewhere on the internet that servers my
> files. I'm currently using header("Location: abc.com") to redirect my
> users to this other site but can't force a download.

Oh, your going to play with the Content-type... This has been discussed
many times before in this group. So i'm pretty sure you'll find out why
it's impossible by definition.

> I can get it to work using readfile() but that means the file moves
> from the high-speed server through my webserver and then to the user,
> which I don't want.
>
> Here's my current setup:
>
> header("Content-Type:application/force-download;name=\"".$path_parts["basename"]."\"");
> header("Content-Disposition:attachment;filename=\"".$path_parts["basename"]."\"");
> header("Content-Length: $size");
> header("Content-Transfer-Encoding: binary");
> header("Location: ".$path["path"]."");

On the first site, you redirect them, not directly to the file, but to a
download.php on the second server.

On the second server you place your download.php that outputs the
headers and the readfile...

-- 
Tim Van Wassenhove <http://home.mysth.be/~timvw/contact.php>


Relevant Pages

  • Force download WITHOUT readfile?
    ... Is it possible to force a download without using the readfile ... My website setup consists of my server that serves the web pages plus ... I can get it to work using readfile() but that means the file moves ...
    (comp.lang.php)
  • Force a download WITHOUT readfile??
    ... I couldn't get it to force a download. ... I can get it to work properly when I use readfile, ... file travels from the high-speed server through my server and to the ... user downloading it whereas using the header; ...
    (php.general)
  • Re: Force download WITHOUT readfile?
    ... readfile, no one specifically said that there is no other way. ... > download.php on the second server. ... > On the second server you place your download.php that outputs the ... So I guess I'm stuck with a redirect. ...
    (comp.lang.php)
  • Re: Problem Updating New Messages from NTTP News Server OE
    ... > as far as I know and he doesn't have a server in his setup. ... download the answer to a problem he had posted in the Outlook group and I had seen the answer almost immediately on July 1. ... sure how taking the check out of the download headers boxes would have helped. ... pane 3) Get headers at a time 4) No check in mark all messages as read when exiting newsgroup ...
    (microsoft.public.windows.inetexplorer.ie6_outlookexpress)
  • Re: OL2003 OAB: Exceeded the download limit set by your administra
    ... 13:50:37 Sam Jones: Synch operation completed ... reference to Outlook Verbose Logging. ... Sort Locale being used by the server is: ... trying to download the OAB then closing Outlook ...
    (microsoft.public.exchange.clients)