• PHP Help PHP Coding
  • Possible to Force Download (PHP Script) from Remote Server W/O Causing Proxy Effect?

So here is the script I have on a force download php, that downloads MP4s to the user:

ob_start();
header("Pragma: public");
header("Expires: " . gmdate("D, d M Y H:i:s", time() + $offset) . " GMT");
header("Cache-Control: must-revalidate, post-check=3600, pre-check=18600");
header("Cache-Control: public", false);
header("Content-Description: File Transfer");
header("Content-Type: " . $type);
header("Accept-Ranges: bytes");
header("Content-Disposition: attachment; filename=\"". $filename .".". $extension ."\";");
header("Content-Transfer-Encoding: binary");
ob_end_clean();
readfile($file);
flush(); 

The file is located on another server I have, so it is remote. From what I've been told, this basically costs double the bandwidth, as the server this script is on now becomes a proxy. Is this true? And, if so, is there a way to do a remote download script without causing a proxy (stream direct from remote server to user).

Thanks
Ryan

    why not just link to the file on the remote server?

      The force download first gives the option to save the file, instead of just loading it into a browser window (you need quicktime pro to save it then), and it stops any hotlinking. The script runs on a temporary link.

      I've tested it with all file grabber programs and they see the link to the force download script and not the actual file. Stops hotlinking.

      It's basically just one big preventative, stopping direct linking, hotlinking, all that.

      Ryan

        seems over the top, you can prevent hot-linking with Apache mod rewrite.

          Yeah, except when people are using Firefox (as it doesn't send header info). A lot of people user firefox now.

          We lost about $3K in bandwidth costs one month to big asian sites hotlinking us. Put a similar script to work for streaming video and it stopped that immediately.

          We had their domains blocked in apache, but firefox users could still do it.

          Ryan

            Write a Reply...