Filename problems when downloading

H

Henke

I have a web application that is used to transfer files to and from a
database. The files are streamed and stored in the database that is.
From one page I can download the files to the client, by clicking on the
filename.
The confirm download popup (the one built-in in IE) is displayed and I can
select either Save or Open.
One the file name row the name of the file is displayed but all " " (spaces)
are replaced with a "+"-sign. Does anybody know why this happens anf how it
can be solved?

Thanks!
/Henke
 
H

Hans Kesting

Henke said:
I have a web application that is used to transfer files to and from a
database. The files are streamed and stored in the database that is.
From one page I can download the files to the client, by clicking on
the filename.
The confirm download popup (the one built-in in IE) is displayed and
I can select either Save or Open.
One the file name row the name of the file is displayed but all " "
(spaces) are replaced with a "+"-sign. Does anybody know why this
happens anf how it can be solved?

Thanks!
/Henke

How do you upload the files? Are you using a "Content-Disposition"
http-header? There you can specify a filename to use.

One reason why spaces are translated to plus-signs could be "URLencoding",
but I don't know why that happened in you code (as you didn't give it).

Hans Kesting
 
H

Henke

Thanks for your answer.
Here is my code:

Response.Buffer = true;
Response.Clear();
Response.ClearContent();
Response.ClearHeaders();
Response.AddHeader("Content-Disposition", "attachment;filename=" +
Server.UrlEncode(doc.FileName));
Response.AddHeader("Content-Length", doc.FileSize.ToString());
Response.Charset = "UTF-8";
Response.ContentType = doc.ContentType;
Response.BinaryWrite(doc.Image);
Response.Flush();
Response.End();
 
H

Hans Kesting

Henke said:
Thanks for your answer.
Here is my code:

Response.Buffer = true;
Response.Clear();
Response.ClearContent();
Response.ClearHeaders();
Response.AddHeader("Content-Disposition", "attachment;filename=" +
Server.UrlEncode(doc.FileName));

Ah, here is the reason. You don't need to "UrlEncode" this filename. This is
what causes the spaces to be replaced with "+".

Hans Kesting
 
H

Henke

Hmm, if I remove the UrlEncode my (å, ä and ö swedish characters) gets
replaced with some strange characters that doesn't exist in our alphabet.
Any other suggestions?

/Henke
 
H

Hans Kesting

Henke said:
Hmm, if I remove the UrlEncode my (å, ä and ö swedish characters) gets
replaced with some strange characters that doesn't exist in our
alphabet. Any other suggestions?

/Henke

Apparently urlencoding works for those special characters (that
seems to be why you used it).
What if you first urlencode to a temporary string variable and
then simply replace "+" back into space? Would that give the desired
result?

Hans Kesting
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,072
Latest member
trafficcone

Latest Threads

Top