web.config配置限制上传文件大小与时间
<httpRuntime maxRequestLength="4096" executionTimeout="100"/>
protected void btn_upload_Click(object sender, EventArgs e) { string filepath = FileUpload1.PostedFile.FileName; string filename = filepath.Substring(filepath.LastIndexOf("\\") + 1); string serverpath = Server.MapPath("upload/") + filename; FileUpload1.PostedFile.SaveAs(serverpath); Page.ClientScript.RegisterStartupScript(GetType(),"","<script>alert('文件上传成功!');</script>"); }