1

I'm calling a web service to download a file, but it always assigns a generic name to the download. Every file I download has the same name.

So I appended "/filename.pdf?a=true" to the end of the URL as follows:

 http://localhost/api/node/content/b52b3136-1cf0-48f2-a109-676a16015612/myfilename.pdf?a=true

Now on Firefox, the file downloads with the desired: myfilename.pdf. But this isn't working on IE or Chrome.

What is wrong with this?

4

1 回答 1

3

You want a header: Content-Disposition: attachment; filename=my_file_name.pdf

Will force a download (instead of an inline display) and set the file name. If you do not force a file name, but allow inline display (via PDF browser plugin) the filename is meaningless, which is, why it is often ignored by browsers.

于 2012-12-24T16:13:44.707 回答