1 context.Response.ContentType = "text/plain";
2 context.Response.Charset = "utf-8";
3 HttpPostedFile file = context.Request.Files["Filedata"];
4 int i = file.ContentLength;
5 string uploadPath =
6 HttpContext.Current.Server.MapPath(@context.Request["folder"]) + "\\";
7
8 if (file != null)
9 {
10 if (!Directory.Exists(uploadPath))
11 {
12 Directory.CreateDirectory(uploadPath);
13 }
14
15 file.SaveAs(uploadPath + file.FileName);
16 //下面这句代码缺少的话,上传成功后上传队列的显示不会自动消失
17 context.Response.Write("1");
18 }
19 else
20 {
21 context.Response.Write("0");
22 }
我今天用uploadify写文件上传的功能当我的文件超过5M就提示context.Request.Files["Filedata"];代码超出范围
要设置webconfig里面的值
<httpRuntimemaxRequestLengthhttpRuntimemaxRequestLength="1048576"
executionTimeout="3600"/>