GrimmGreen
New Member
I have been playing around with asp.net webforms controls to learn how to use them better and I seem to have gotten myself in some trouble with the fileupload control. I noticed that when I upload img's the code I wrote works but when I try to upload a PDF or a RAR file I get an error saying that\[quote\] the connection to localhost has been interupted\[/quote\]This is my code:\[code\]<div id="center"> <asp:FileUpload ID="FileUpload1" runat="server" /> <br /> <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" /> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label></div>protected void Button1_Click(object sender, EventArgs e) { if (FileUpload1.HasFile) { try { string filename = FileUpload1.FileName; FileUpload1.SaveAs(Server.MapPath("~/Files/") + filename); Label1.Text = "File has been uploaded"; } catch (Exception ex) { Label1.Text = "The file could not be uploaded"; } } }\[/code\]What is the problem? Why can't I upload other file types?