MozillaZine

Download problem with spaces in filename

Discuss building things with or for the Mozilla Platform.
mohamed.arafath
 
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.ClearContent();
HttpContext.Current.Response.Clear();
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);
fs.Close();
HttpContext.Current.Response.BinaryWrite(bite);
}


Reply me ASAP

makaiguy

User avatar
 
Posts: 16783
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 http://www.faqs.org/rfcs/rfc1738.html, and scroll down to the discussion of Unsafe characters.
Doug Wilson, "The Makai Guy"
Win10 (64bit): FF Quantum 70.0.1 (64bit), TB 60.9.0 (32-bit) ║ Android 8.0/7.1.1: FF Mobile 68.2.0, No TB for Android available, dammit!
What a fool believes he sees, no wise man has the power to reason away - Doobie Brothers

harg
 
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, http://www.leevalleypark.org.uk/media/v ... 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 http://www.leevalleypark.org.uk/en/cont ... 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