11月7号的博客 张孝祖
protected void Page_Load(object sender, EventArgs e) { }//初始化页面 protected void OK_Click(object sender, EventArgs e) //点击上传时 { title = Title.Text; keyWord = Keyword.Text; author = Author.Text; fileaddress = MapPath(fu.FileName); filetype = System.IO.Path.GetExtension(fu.FileName).ToString(); //类型自动获取 if (title=="") { Response.Write("<script>alert('请填写必填项目');</script>"); } else { if (fu.HasFile == true) { fu.SaveAs(MapPath(fu.FileName)); if (fu.PostedFile.ContentLength < 1036000) //上传文件小于1m,加3分 { Application["MyIntegration"] = Convert.ToString(Convert.ToInt32(Application["MyIntegration"].ToString()) + 1); } if (fu.PostedFile.ContentLength > 1036000 && fu.PostedFile.ContentLength < 3072000) //上传文件大于1m小于3m,加2分 { Application["MyIntegration"] = Convert.ToString(Convert.ToInt32(Application["MyIntegration"].ToString()) + 2); } if (fu.PostedFile.ContentLength > 3072000) //上传文件大于3m,加3分 { Application["MyIntegration"] = Convert.ToString(Convert.ToInt32(Application["MyIntegration"].ToString()) + 3); } Response.Redirect("UpLoadContent.aspx"); } else { Response.Write("<script>alert('请选择上传文件');</script>"); } } } }
这次的修改,把type的获得从让用户填写改为自动获得,积分的增加,也从固定加一,改为根据上传大小来增加积分
上传的文件越大,加的积分越多,当然不是无限大就给无限多分,最多加3分。