Thursday, March 31, 2011

Renaming File on another server as user downloads it

Hello all,

I am allowing users to download a file from another server just by giving them the link.

However, the files are always named "file.zip" when users try to download it. I was hoping I could use maybe JavaScript to rename the file for them to something more appropriate.

How can I do this? Is this possible?

Would appreciate any help.

Thanks all

UPDATE

How about saving that file to my server and as I do this, let the users download it? Can users start downloading an un-fully downloaded file?

From stackoverflow
  • No its not possible, the file.zip will be in the Content-Disposition header sent by the server, there is nothing you can do in Javascript to intercept and modify it.

  • This is not possible. The only way to show specific file names when downloading files is controlling the remote server and setting it to set a specific http header.

  • I'm fairly sure Javascript won't let you do this.

    A better option might be to send a HTTP Content-Disposition header, like so:

    Content-Disposition,attachment; filename=foobar.zip
    

    where foobar.zip is the name you wish the file to be called.

    Abs : I can use this method while still having the file on the other server?
    12345 : This has to be done from the server which actually hosts the file, so I guess if you don't have access to that server this won't help. Unfortunately, I think it's the only way.

0 comments:

Post a Comment