PDA

View Full Version : Download files in HR from another site.


Liso
02-01-2004, 12:58 PM
Hello

I have 2 files .rar. The size of each file is 5Mb.

In my website, I "force the download" with a script like "download.php?id=44".

And, when the download starts, he can only download 1Mb, why ?

The problem is when i try to download the same file with a blank link (like here) http://my_domain/the_file.rar the download is complete.

Anybody have an idea to resolv this problem, please ?

Thanks a lot.
I am not English, sorry for the language...

Viper007Bond
02-01-2004, 04:49 PM
What's the document's code? This should do it:

<?php

$files = array(
"44" => "http://my_domain/the_file.rar"
);

$id = $_GET['id'];

header("Content-Type: application/force-download");
header("Location: ".$files[$id]."");

?>

Liso
02-01-2004, 06:30 PM
Hi
Yes, my code is

header("Content-Type: application/force-download");
header('Content-Disposition: attachment; filename="' .basename($url). '"');
header("Content-Description: File Transfert");
header("Content-Length: ".filesize($url)); // je pensais que ceci marcherait
header("Pragma: no-cache");
header("Expires: 0");
readfile($url);


And the problem is only with files of hostrocket, because with files on others hosts there is no problem...

Have you got an idea ?

Thanks

Viper007Bond
02-01-2004, 08:31 PM
Is this a free account or a paid? If it's free, that could be the reason. Free accounts don't have full PHP.

Liso
02-02-2004, 05:22 AM
I have a free account, but the php code is not in a HR page...

Another idea ?

Do you think there is a better board to write this and a HR staff answer me ?

Liso
02-02-2004, 05:57 AM
Hi

Your script works ! Files from HR are downloaded correctly.
Maybe my script was wrong...

Thanks a lot !

Viper007Bond
02-02-2004, 06:10 AM
:)

I can't remember if my script actually forces download or not, but it's not a big deal on RAR files as they are always downloaded unlike audio and video which can be streamed.