views:

130

answers:

3

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?

+2  A: 

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.

AnthonyWJones
A: 

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.

Tiago
+1  A: 

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.

12345
I can use this method while still having the file on the other server?
Abs
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.
12345