- 注册时间
- 2013-8-16
- 最后登录
- 2013-8-16
- 阅读权限
- 10
- 积分
- 11
- 精华
- 0
- 帖子
- 4
|
本帖最后由 1640102138 于 2013-8-16 11:40 编辑
我在本机用VS 2010调试上传控件FileUpload 时是没有问题的,但是上传到服务器后,总是提示上传失败,前端JS方法onUploadError(e)里的 "e"也不见有什么其它属性, 请问这是用来搞笑的吗?
以下是我的上传后台代码:
- bool flag = false;
- string strMsg = string.Empty;
- try
- {
- // 获得程序路径
- string tempFile = Request.PhysicalApplicationPath;
- //找到目标文件对象
- HttpPostedFile uploadFile = Request.Files["Fdata"];
- string cmd = Request.Params["cmd"];
- // 如果有文件, 则保存到一个地址
- string _json = Request.Params["data"];
- string fid = Request.Params["fid"];
- JArray ja = (JArray)JsonConvert.DeserializeObject(_json);
- Maticsoft.BLL.major bll_major = new Maticsoft.BLL.major();
- if (cmd == "addRow")
- {
- major _major = new major();
- _major.key = ja[0]["key"].ToString();
- _major.ctype = ja[0]["ctype"].ToString();
- _major.text = ja[0]["text"].ToString();
- _major.years = Convert.ToInt32(ja[0]["years"].ToString());
- _major.nodetype = -1;
- _major.fid = int.Parse(fid);
- _major.logo = uploadFile.FileName;
- flag = bll_major.Add(_major);
- }
- if (cmd == "updateRow")
- {
- int id = Convert.ToInt32(ja[0]["id"].ToString());
- major _major = bll_major.GetModel(id);
- _major.key = ja[0]["key"].ToString();
- _major.ctype = ja[0]["ctype"].ToString();
- _major.text = ja[0]["text"].ToString();
- _major.years = Convert.ToInt32(ja[0]["years"].ToString());
- _major.logo = uploadFile.FileName;
- flag = bll_major.Update(_major);
- }
- if (flag)
- {
- if (uploadFile.ContentLength > 0)
- {
- string _path = Server.MapPath("/admin/usermanage/UploadImage/");
- uploadFile.SaveAs(string.Format("{0}{1}", _path, uploadFile.FileName));
- ImageClass.MakeThumbnail(_path + uploadFile.FileName, Server.MapPath(_path+"x" + uploadFile.FileName), 0, 60, "H", System.Drawing.Imaging.ImageFormat.Png);
- }
- }
- }
- catch (Exception ex)
- {
- strMsg = ex.Data+"\\n"+ex.Message+"\\n"+ex.InnerException;
- }
- Response.Write((strMsg == "" ? flag.ToString() : strMsg));
复制代码
|
|