How to prevent IE from adding "[1]" before char dot to the default file name of a "Save as" dialog?

First of all, I'm sorry if this is not the perfect place to ask this question, I just can't find a more proper one. 

Here is the thing, my website provides some kind of  file downloads, if the suggested file name has more than one dot chars('.'), IE will add a "[1]" before the first dot. For example, if my suggested file name is "aaa bbb.doc.zip", the default file name apperas in Save as dialog of IE will become "aaa bbb[1].doc.zip". Here is my code:

 

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

As you can see, I surrounded the file name with double quotes, which works perfectly in FireFox, but not in IE. Searching does not help me a lot, because all the search engines will treat "[1]" as "1",  this site included.

How can I get through this, and let IE do exactly what I wanted it to do? 

Thanks! 


My blog (zh-CN)
Be and awear of who you are.
0
deerchao
10/14/2007 7:22:00 PM
asp.net.client-side 24353 articles. 1 followers. Follow

7 Replies
566 Views

Similar Articles

[PageSpeed] 23

i believe if you urlencode the filename (your periods would be replaced with %2e), you can avoid having IE alter the name. 

 


Mike Banavige
~~~~~~~~~~~~
Need a site code sample in a different language? Try converting it with: http://converter.telerik.com/
0
mbanavige
10/14/2007 7:57:12 PM

 It's not working.

I UrlEncoded the file name, and got "aaa+bbb[1].doc.zip" with IE, "aaa+bbb.doc.zip" with FireFox.

And HtmlEncode won't work: "aaa bbb[1].doc.zip" and "aaa bbb.doc.zip", which is the same as not encoded.
 


My blog (zh-CN)
Be and awear of who you are.
0
deerchao
10/14/2007 9:14:02 PM

looks like you'll need to manually encode the periods instead of using the built in urlencode

something like this:

filename = filename.Replace(".", "%2e");
 
Mike Banavige
~~~~~~~~~~~~
Need a site code sample in a different language? Try converting it with: http://converter.telerik.com/
0
mbanavige
10/14/2007 9:54:34 PM
mbanavige:

i believe if you urlencode the filename (your periods would be replaced with %2e), you can avoid having IE alter the name. 

 

Thank you for the word "periods" (my poor English slows me down again), I googled ' IE peirod filename "save as" ', and got this from http://support.microsoft.com/kb/325630 :

To work around this bug, you must not allow files with two periods. You can also manually change the file name to remove the brackets.

 

It seems I have to tell my users to use FireFox, because that's impossible to change the files' name, they are maps for Blizzard Warcraft III, which requires these names exactly. 


My blog (zh-CN)
Be and awear of who you are.
0
deerchao
10/14/2007 9:54:45 PM

mbanavige:

looks like you'll need to manually encode the periods instead of using the built in urlencode

something like this:

filename = filename.Replace(".", "%2e");

 

 

It's still not working.

FireFox showes %2e in file names without decode, IE don't even show a save as dialog, it display the stream content directly. 


My blog (zh-CN)
Be and awear of who you are.
0
deerchao
10/14/2007 9:58:05 PM

a couple tweaks for you.

1) looks like we should only encode the periods which are not the last period.

2) since the bug we're avoiding is an IE bug, the fix should target that browser only.

Try this code which worked for me.  You'll need to convert to c# but it should clear this issue up:

'only if it's IE
If Request.Browser.Browser.Contains("IE") Then
   'extract the file extension (with the period)
   Dim ext As String = filename.Substring(filename.LastIndexOf("."))
   
   'extract the files name up to but not including the last period
   Dim name As String = filename.Remove(filename.Length - ext.Length)

   'encode any periods in the name
   name = name.Replace(".", "%2e")

   'rebuild the name and extension
   filename = name & ext

End If
 
Mike Banavige
~~~~~~~~~~~~
Need a site code sample in a different language? Try converting it with: http://converter.telerik.com/
0
mbanavige
10/14/2007 10:32:41 PM

Sorry, I have to go to bed now. I'll test it tomorrow, but if it works for you, I think it will work for me.

Thanks for your patience! 

 --------------------

Update: it works, Thank you very much!


My blog (zh-CN)
Be and awear of who you are.
0
deerchao
10/14/2007 11:05:20 PM
Reply:

Similar Artilces:

Save or open file download dialog should include "Save in default location" and "Save somewhere else" options
Name: Eric Carter Email: mozillafeedback Product: Firefox Summary: Save or open file download dialog should include "Save in default location" and "Save somewhere else" options Comments: When i click a download link I'm presented with the choice to open that file with a program on my computer, or save it to a location. After that, depending on my configuration I either get a second dialog asking where i want to save that file, or it goes to the default download location. Most of the time i want to save to my default downloads location, but sometime...

Save or open file download dialog should include "Save in default location" and "Save somewhere else" options #2
Name: Eric Carter Email: mozillafeedback Product: Firefox Summary: Save or open file download dialog should include "Save in default location" and "Save somewhere else" options Comments: When i click a download link I'm presented with the choice to open that file with a program on my computer, or save it to a location. After that, depending on my configuration I either get a second dialog asking where i want to save that file, or it goes to the default download location. Most of the time i want to save to my default downloads location, but sometime...

.ALLCOL("%COLUMN%", " ", ", ", ", ")
Do you know anyway for me to exclude a subset of columns returned by this function. We have two columns (rec_user and rec_datetime) which are in all of our tables, but when generating triggers I want automatically generate a script which does not include those two columns but does include all other columns in that table. Bruce I should add that I am using PD 9.0.0.580. Bruce "Bruce Lamb" <lamb.bruce@mayo.edu> wrote in message news:6HgI315nCHA.155@forums.sybase.com... > Do you know anyway for me to exclude a subset of columns returned by this > function. ...

Precedence of "where" ("of", "is", "will")?
Nobody on #perl6 today could answer this one. Is: Str | Int where { $_ } the same as: (Str | Int) where { $_ } or: Str | (Int where { $_ }) ? Followup questions, Mr. President: What kind of operators are "where", "of", "is", and "will"? Is there a reason that S03 doesn't list them? What are their precedence(s)? -- Chip Salzenberg - a.k.a. - <chip@pobox.com> Open Source is not an excuse to write fun code then leave the actual work to others. Chip Salzenberg writes: &...

while saving the file "Save as Type" in SaveDialogBox shows "MicrosoftExcelSheet" and "AllFiles", how can i restrict "AllFiles" and show only "MicrosoftExcelSheet" ..
Below is code written for opening XLFile.  HttpContext.Current.Response.Clear();HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + astr_FileName); HttpContext.Current.Response.AddHeader("Content-Length", abyte_Data.Length.ToString()); HttpContext.Current.Response.ContentType = astr_ContentType; //octet-stream"; or //"application/vnd.ms-excel"; HttpContext.Current.Response.BinaryWrite(abyte_Data);    Udaya.M...

quotes, quotes, quotes...
I am getting this error and I know what is causing it, but I have no idea how to fix it, any help would be great. The script steps through the /var/log/messages file on a linux server and puts The entries into a mysql database. However when it gets to the 'hlt' line in the messages file it just barfs. The single quotes are freaking it out. I know about quotes but not how to use in this situation. Thanks, Paul Error: May 27 17:53:00 localhost kernel: Checking 'hlt' instruction... OK. <----- doesn't like this in the messages file DBD::mysql::st exec...

Swap a "1" or "0" for a "Y" or "N"
I have a sql query that returns rows of data and one field returns a 1 (which means yes) or a 0 (which means no).  On my vb.net page, how do I replace the 1 with a Yes and the 0 with a No?  Or do I do this in the sql?  How do I do this in sql?Never make important decisions on a Monday! By default, VB.Net can understand 1 as Yes and 0 as No.I believe you are using those DB values for your Boolean Operations.Try to use If <DBValue> then <Operation>. If you are really need Yes/No .... Declare boolean variable in VB.net and set those variables. Thanks and R...

"save as" and "save link as" dialog flickers
On a new Mandriva 2007.1 system Firefox 2.0.0.3 and Seamonkey 1.1.1 both have a glitch in the "save as" (for an open page) and "save link as" (Firefox)/ "save link target as" (Seamonkey) for right click on a link dialogs. When the dialog comes up it's like there are two copies and it is flickering back and forth between them rapidly. Or possibly the dialog is resizing itself quickly. The "two" dialogs are vertically aligned but the right edge jumps back and forth. Identical copies of these two browsers did NOT do this on Mandriva 2006...

"File" to "File$date"
Okay... Thanks for all your answers! From all, I combinded the perfext solution: rename("test.txt", "test" . &heute() . ".txt"); sub heute { return (localtime(time))[3] . (localtime(time))[4] . = ((localtime(time))[5] 1900); } Thanks ;) Andreas -----Urspr=FCngliche Nachricht----- Von: Sudarshan Raghavan [mailto:sraghav@india.hp.com]=20 Gesendet: Samstag, 14. September 2002 15:21 An: Perl beginners Betreff: Re: AW: Rename "File" to "File$date" On Sat, 14 Sep 2002, Sudarshan Raghavan wrote: >=20 > #!/...

"-" not "_"
I wrote a SQL statement in the data tab. I wrote a bunch of alaises as example ' word-type ' but when I hit the layout tab it converts the "-" to "_". So now my field name is ' word_type '. Is there any way to prevent this? CardGunner Don' use a hypen ( - ).  It isn't a valid character for column names.   See http://searchsqlserver.techtarget.com/expert/KnowledgebaseAnswer/0,289625,sid87_gci1188931,00.html   Here's an excerpt about column names: Letters as defined in the Unicode Standard 2.0 Decimal numbers from either B...

Using "+" or "||"
Using SQLAnywhere 5.5.04, I've gotten into the habit of using "||" in ISQL to indicate a string concatenation. I needed to paste my SQL statement into the PowerBuilder script painter for some embedded SQL, and PB didn't like the "||" very much at all. I changed it to "+" and it seems to be ok. Do these two operators indicate ~exactly~ the same thing? moin, afaik these two's are not the same! if you're using "||" and any term is NULL then in the resultstring the term will be ignored if you use "+" then the resu...

double quote
hello there...  i tried everything of think but not working the way i wanted to be... not sure what i'm missing...i'm generating a <span> in code behind and then using in javascript.... here is what i'm doing code behind: int i=0string _keywordID = "keyword";string _name = row["visit_info_nm"].ToString().Trim(); String _getElementByID = String.Format("<span id='{0}' OnClick = \"document.getElementById('{1}').value='{2}';\">{3}</span><br>", i, _keywordID, _name, _name); here is what it generate : <span id='1' OnClick = \"document.getElementById('keyword')...

"To" and "From" missing
When I print emails, the words "To" and "From" are blank, even though the "To" name and "From name (addresser, addressee) do show up. This is not a problem for other users on my system. Suggestions In mailbox right click, view. On the message window, right click and choose print options. Make sure print header is checked. -- Barry Merchant NSC Volunteer SysOp *** no email unless requested please!! *** > In mailbox right click, view. On the message window, right click and > choose print options. Make sure prin...

replace the "." with a ","
Oi.... I need to build a small programm in ASP.NET and chose to use C# for it.Now i got everything working but there's one little problem.the first textbox is a double. I need to make it so that when someone enters a "." then it gets replaced by a ","any ideas?Ghan  string blah = "4.2.2.2";blah = blah.Replace(".", ",");Ryan Ryan OlshanASPInsider | Microsoft MVP, ASP.NEThttp://ryanolshan.comHow to ask a question...

Web resources about - How to prevent IE from adding "[1]" before char dot to the default file name of a "Save as" dialog? - asp.net.client-side

Resources last updated: 1/11/2016 11:45:16 PM