Force download from an external server and rename

I need help with a problem in the tool that I am developing.

I need to download an external file and rename it, but without using readfile (), file_get_contents () or fread () (the files are too large to read them on the server and upload them again to the guest PC).

I tried first:

the code:

header("Location: http://www.example.com/example_download.zip");

It works for loading, but not for example_download.zip renaming.

So I tried with readfile ():

the code:

header("Content-Disposition: attachment; filename="example_download_2.zip"\n\n");
header("Content-Type: application/force-download");
    readfile("http://www.example.com/example_download.zip");
    exit;

It works well with the code above, first downloading the remote file on the server, renaming it and sending it to the visitor with a new name, but the use of the resources of this process is very large, as well as the use of bandwidth.

, , , . ?

+5
2

HTML5 , , download:

<a href="http://www.example.com/example_download.zip" download="custom_filename.zip">
    Link
</a>

:

http://developers.whatwg.org/links.html#attr-hyperlink-download http://updates.html5rocks.com/2011/08/Downloading-resources-in-HTML5-a-download

+4

. php script URL-, HTTP- url script, . , .

+2

All Articles