By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,561 Members | 3,010 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,561 IT Pros & Developers. It's quick & easy.

Recommend a filename with space chars for download "Save As..." dialog

P: n/a
I used these codes to provide a default "Save As" filename for
browsers:

Response.AppendHeader("Content-Disposition",
"attachment; filename=" + fileName);
Response.ContentType = "application/octet-stream";

But if there are space chars in the file name, FireFox would split the
recommed file name, and use the first part only. For example, if
fileName=="aaa bbb.watever", then the "Save As" dialog will take "aaa"
as the filename.

And if there are more than one dots(char '.'), IE will add a "[1]"
before the first dot char. For example, if
fileName=="aaa.bbb.whatever", IE will show "aaa[1].bbb.whatever".

For some reason, I'd like to make these default file names exactly as
what I recommeded, Is there any way to do this?

Thanks!

Note: I tried UrlEncode and HtmlEncode the fileName in HTTP headers,
but none of them worked.

Oct 14 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On Oct 14, 8:39 pm, deerchao <deerc...@gmail.comwrote:
I used these codes to provide a default "Save As" filename for
browsers:

Response.AppendHeader("Content-Disposition",
"attachment; filename=" + fileName);
Response.ContentType = "application/octet-stream";

But if there are space chars in the file name, FireFox would split the
recommed file name, and use the first part only. For example, if
fileName=="aaa bbb.watever", then the "Save As" dialog will take "aaa"
as the filename.

And if there are more than one dots(char '.'), IE will add a "[1]"
before the first dot char. For example, if
fileName=="aaa.bbb.whatever", IE will show "aaa[1].bbb.whatever".

For some reason, I'd like to make these default file names exactly as
what I recommeded, Is there any way to do this?

Thanks!

Note: I tried UrlEncode and HtmlEncode the fileName in HTTP headers,
but none of them worked.
OK, I figured out the first problem:
Surround the filename with double quotes.
Now FireFox works perfectly, but IE still adds [1] before the first
dot char.

Oct 14 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.