Force download from external server and rename

Discussion in 'PHP' started by dannet, May 15, 2009.

  1. #1
    Hello, I need help with a problem in a tool that Im developing.

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

    I have tried first with:
    header("Location: http://www.example.com/example_download.zip");
    Code (markup):
    It works for the download, but no for the example_download.zip rename.

    So I have tried with readfile():

    header("Content-Disposition: attachment; filename="example_download[B]_2[/B].zip"\n\n");
    header("Content-Type: application/force-download");
        readfile("http://www.example.com/example_download.zip");
        exit;
    Code (markup):
    With the above code it works well, downloading the remote file first on the server, renaming it and after sending it to the visitor with the new name, but the resources usage of this process is very high, and also the bandwidth usage.

    So I'm looking for a way to generate a force-download of an external file, renaming it on the fly and generating a download with the new name but downloading directly from the source. I'ts possible?

    Thanks in advance
    Regards
     
    dannet, May 15, 2009 IP
  2. Sky AK47

    Sky AK47 Member

    Messages:
    298
    Likes Received:
    8
    Best Answers:
    1
    Trophy Points:
    45
    #2
    Hm...that's a hard one, I have googled and tried myself a bit but I don't think this is possible without the function you named.
     
    Sky AK47, May 16, 2009 IP
  3. dannet

    dannet Well-Known Member

    Messages:
    864
    Likes Received:
    30
    Best Answers:
    0
    Trophy Points:
    153
    #3
    Thanks for your reply.

    Yes, I have searched too and talking with a lot of people and it seems like it is not possible without the functions :(
     
    dannet, May 17, 2009 IP