Download problem with spaces in filename

Discuss building things with or for the Mozilla Platform.
Posts: 1
Joined: September 25th, 2013, 7:00 am

Post Posted September 25th, 2013, 7:13 am

Hi ,

I am Arafath . I am trying to download the uploaded file from commonshare path using ASP.NET.
i have my files with file name as " Fixed fhfgfhfhfghf). dfadasdasdasda. asdasdada. fgdfgdfgd. IssuesBuild.xlsx" . the problem here is IE and Chrome downloads the file with correct name with format. Mozilla truncates the words after the first space and remove the file format as well. dont know how to fix that .

Kindly help me to fix the issues.

below is the code .

string path = @"C:\Fixed (fhfgfhfhfghf).dfadasdasdasda.dasdasdada.fgdfgdfgd.IssuesBuild.xlsx";
file = new FileInfo(path);
if (file.Exists)
BinaryReader fs = new BinaryReader(file.OpenRead());
HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + Path.GetFileName(file.Name));
HttpContext.Current.Response.AddHeader("Content-Length", file.Length.ToString());
HttpContext.Current.Response.ContentType = "application/octet-stream";
byte[] bite = fs.ReadBytes((int)file.Length);

Reply me ASAP


User avatar
Posts: 16890
Joined: November 18th, 2002, 6:44 pm
Location: Somewhere in SE USA

Post Posted September 25th, 2013, 7:52 am

Try replacing the space with the three characters %20 when specifying the URL in Firefox. (I suspect the other browsers are probably doing this automatically.)

See, and scroll down to the discussion of Unsafe characters.
Doug Wilson, "The Makai Guy"
Win10 (64bit): FF 84.0.1 (64bit), TB 78.6.0 (32-bit) ║ Android 10: FF Mobile 84.1.2, No TB for Android available, dammit!
What a fool believes he sees, no wise man has the power to reason away - Doobie Brothers

Posts: 9
Joined: November 8th, 2004, 3:12 am

Post Posted February 23rd, 2014, 10:35 am

This is a problem even with sites that do encode the spaces. For example, ... 20Weir.pdf downloads as Ware with no file extension.

[Edit]: The forum hides the %20 section due to the length of the link, but check the URL -- it is the first download link at ... here-maps/ -- ending as /Maps/Ware%20to%20Dobbs%20Weir.pdf

I would not mind so much that it truncates the name, but losing the .pdf at the end is catastrophic -- it means that the file cannot even be displayed until it has been properly renamed.

- -

Currently testing in Aurora 29.0a2 but I previously had similar on other sites in FF 27 too.
Windows 7 pof 64 bit

Return to Mozilla Development

Who is online

Users browsing this forum: No registered users and 1 guest