Hi, I have file upload control and upload button in my application asp:FileUpload ID="FileUpload1" runat="server" Width="250px" /> asp:Button runat="server" ID="btn_upload" Text="Upload" onclick="btn_upload_Click" i have included it in .aspx file when i browse any file using this control and click on upload button i got the connection timeout error. .this case is only with fileupload control,but if i dint browse any file and click on upload button then this error is not coming, click event of upload button(btn_upload_Click) gets fired but with Fileupload control after browsing any file click event of upload button not firing. .why this problem occurs..plz help
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
please try after including this in your web.config file
<system.web>
<httpRuntime executionTimeout="999999" maxRequestLength="2097151" />
</system.web>
回答2:
In aspx file:
<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:Button ID="Button1" runat="server" Text="Upload"
onclick="Button1_Click" />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
In code behind:
protected void Button1_Click(object sender, EventArgs e)
{
string filename = Path.GetFileName(FileUpload1.FileName);
FileUpload1.SaveAs(Server.MapPath("~/") + filename);
Label1.Text = "Upload status: File uploaded!";
}
You can also refer to this link:
http://asp.net-tutorials.com/controls/file-upload-control/