need help about download large files
am 02.11.2007 21:24:07 von Francesco
Hi guys,
I wrote a little script to authorize the users to download a file
without showing the actual location of the file.
I wrote something like
if(authorized) {
$file_path = "$site_path" . "/anAbsolute/pathTo/MyFile.zip";
$file_mime = "application/x-zip-compressed";
$file_name = "new_name.zip";
header("Content-Type: application/x-zip-compressed)
header("Content-Transfer-Encoding: binary");
header("Content-Length: ". filesize($file_path));
header("Content-Disposition: inline; filename=".$file_name);
header("Expires: 0");
header("Cache-Control: no-cache, must-revalidate");
header("Cache-Control: private");
header("Pragma: public");
readfile($file_path);
}
this works perfectly for most of the files. But I can't use it because:
* MyFile.zip size is around 300 mb.
* max_time_limit on the server is around 2 minutes, while the script
would need more time to complete the task.
* I cannot override max_time_limit because i'm hosted and it's forbidden.
Is there any other way to achieve this goal?
Thanks for your help
Francesco
Re: need help about download large files
am 02.11.2007 21:51:07 von Bucky Kaufman
"Francesco" wrote in message
news:472b8783$0$4787$4fafbaef@reader4.news.tin.it...
> Hi guys,
> I wrote a little script to authorize the users to download a file without
> showing the actual location of the file.
>
> I wrote something like
>
> if(authorized) {
> $file_path = "$site_path" . "/anAbsolute/pathTo/MyFile.zip";
>
> $file_mime = "application/x-zip-compressed";
> $file_name = "new_name.zip";
>
> header("Content-Type: application/x-zip-compressed)
> header("Content-Transfer-Encoding: binary");
> header("Content-Length: ". filesize($file_path));
> header("Content-Disposition: inline; filename=".$file_name);
> header("Expires: 0");
> header("Cache-Control: no-cache, must-revalidate");
> header("Cache-Control: private");
> header("Pragma: public");
>
>
> readfile($file_path);
> }
>
> this works perfectly for most of the files. But I can't use it because:
>
> * MyFile.zip size is around 300 mb.
>
> * max_time_limit on the server is around 2 minutes, while the script would
> need more time to complete the task.
>
> * I cannot override max_time_limit because i'm hosted and it's forbidden.
>
> Is there any other way to achieve this goal?
Yeah - there's supposed to be something in the content type or
transfer-encoding about "multi-part binary".
HTTP wasn't meant to transfer binaries, so an http session isn't long enough
for much more than a LOT of text.
By doing the "multi-part binary" thing, you're letting the browser/server
auto-negotiate a whole buncha http transactions, each sending a chunk of the
file until the whole thing is complete.