ASP.NET fileupload control, can't upload files with spaces in the name
I have a fileupload control that I'm using to upload file. When I upload a file with a name that has no spaces in it eg. "example.txt", it works fine. But when I try to upload a file with a name like "example example.txt" the file does not go through. Here is my code:
<asp:FileUpload ID="fuUpload" runat="server" />
if (fuUpload.HasFile)
{
try
{
string filename = Path.GetFileName(fuUpload.FileName);
fuUpload.SaveAs(Server.MapPath("uploads\\" + filename));
lStatusLabel.Text = "Upload status: File uploaded!";
}
catch (Exception ex)
{
lStatusLabel.Text = "Upload status: The file could not be uploaded. The foll开发者_StackOverflow中文版owing error occured: " + ex.Message;
}
}
fuUpload.HasFile does not even return true, does anyone know why this is?
精彩评论