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>");
    }

 

posted @ 2014-08-05 17:41  波波乐园  阅读(131)  评论(0编辑  收藏  举报