net上传文件大小|net中怎样设置文件上传的大小

|

① .net fileupload控件上传大文件(至少50M以上)

注意修胡猛改笑做信了上传文件的大小,就一定要修改超时的时间在web.config中的<system.web></system.web>内加入如下代码: <httpRuntime executionTimeout="600" maxRequestLength="951200" useFullyQualifiedRedirectUrl="true" minFreeThreads="8" minLocalRequestFreeThreads="4" appRequestQueueLimit="100" enableVersionHeader="true"/碰轮>

② .net 获取以上传文件大小 并输出

用FileUpload上传……给它起个ID。然后获取上传文件的大小this.FileUpload1.PostedFile.ContentLength

③ asp.net怎样上传超过2GB的大文件

用upload第三方的控件,还支持多文件批量上传,上传大小不限制(可以自己设置).网上有这个控件,很好用。

④ .net中,怎样设置文件上传的大小。

实际例子(已上传图片为例)protected void UpImg_Click(object sender, EventArgs e)//上传图片 { if (FileUpload1.PostedFile.ContentLength < 500000)//100000为100K { string fileFullname = this.FileUpload1.FileName; string dataName = DateTime.Now.ToString("yyyyMMddhhmmss"); string fileName = fileFullname.Substring(fileFullname.LastIndexOf("\\") + 1); string type = fileFullname.Substring(fileFullname.LastIndexOf(".") + 1); if (type == "bmp" || type == "jpg" || type == "gif" || type == "JPG" || type == "BMP" || type == "GIF") { this.FileUpload1.SaveAs(Server.MapPath("../upload") + "\\" + dataName + "." + type); string ProImg = "upload/" + dataName + "." + type; this.txtProImg.Text = "upload/" + dataName + "." + type; } else { Response.Write("<script language='javascript'>alert('支持格式:||gif|bmp|');</script>"); } } else { Response.Write("<script language='javascript'>alert('你的图片已经超过500K的大小!');</script>"); } }web.config配置web.config文件的内容大体如此:<globalization requestEncoding="gb2312" responseEncoding="gb2312"/><sessionState mode="InProc" cookieless="false" timeout="20"/> <httpRuntime maxRequestLength="47185920"> </httpRuntime></system.web></configuration>注意在文件中的位置,讲解:<sessionState mode="InProc" cookieless="false" timeout="20"/>//cookieless="false",不使用cookies//timeout="20",会话时间为20分钟,单位是分钟,这里可自行修改<httpRuntime maxRequestLength="47185920">//站点默认上传的最大文件


赞 (0)