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

Filename problems when downloading

P: n/a
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
Nov 18 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Henke wrote:
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
Nov 18 '05 #2

P: n/a
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();
"Hans Kesting" <ne***********@spamgourmet.com> skrev i meddelandet
news:%2****************@TK2MSFTNGP11.phx.gbl...
Henke wrote:
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

Nov 18 '05 #3

P: n/a
Henke wrote:
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
Response.AddHeader("Content-Length", doc.FileSize.ToString());
Response.Charset = "UTF-8";
Response.ContentType = doc.ContentType;
Response.BinaryWrite(doc.Image);
Response.Flush();
Response.End();
"Hans Kesting" <ne***********@spamgourmet.com> skrev i meddelandet
news:%2****************@TK2MSFTNGP11.phx.gbl...
Henke wrote:
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

Nov 18 '05 #4

P: n/a
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

"Hans Kesting" <ne***********@spamgourmet.com> skrev i meddelandet
news:e8**************@tk2msftngp13.phx.gbl...
Henke wrote:
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
Response.AddHeader("Content-Length", doc.FileSize.ToString());
Response.Charset = "UTF-8";
Response.ContentType = doc.ContentType;
Response.BinaryWrite(doc.Image);
Response.Flush();
Response.End();
"Hans Kesting" <ne***********@spamgourmet.com> skrev i meddelandet
news:%2****************@TK2MSFTNGP11.phx.gbl...
Henke wrote:
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


Nov 18 '05 #5

P: n/a
Henke wrote:
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

Nov 18 '05 #6

P: n/a
Yes that was a good idea, thanks for your help!

/Henke

"Hans Kesting" <ne***********@spamgourmet.com> skrev i meddelandet
news:uH**************@TK2MSFTNGP12.phx.gbl...
Henke wrote:
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

Nov 18 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.