?1.放在ajax.BeginForm里,不好使,同asp.net 表單中?fileupload控件不支持ajax差不多吧,如果異步的話可以借助jquery.form.js,很方便
2.
? //上傳文件
??????????? object fielLogoImg = Request.Files["fielLogoImg"];
??????????? if (fielLogoImg != null)
??????????? {
??????????????? string fileExtension = string.Empty;
??????????????? string filename = string.Empty; ;
??????????????? string filePathName = string.Empty;
??????????????? if (Request.Files["fielLogoImg"].ContentLength > 0 && Request.Files["fielLogoImg"].ContentLength <= 51200)
??????????????? {
??????????????????? bool fileJudge = false;
??????????????????? string path = Server.MapPath(Framework.Configuration.UserFilePath + CurrentUser.UName);
??????????????????? string uploadFileName = Path.GetFileName(Request.Files["fielLogoImg"].FileName);
??????????????????? fileExtension = System.IO.Path.GetExtension(Request.Files["fielLogoImg"].FileName).ToLower();
??????????????????? filename = "Logo" + fileExtension;
??????????????????? string[] ae = { ".gif", ".bmp", ".jpg", ".jpeg", ".png", ".tif" };
??????????????????? for (int i = 0; i < ae.Length; i++)
??????????????????? {
??????????????????????? if (fileExtension == ae[i])
??????????????????????? {
??????????????????????????? fileJudge = true;
??????????????????????? }
??????????????????? }
??????????????????? if (fileJudge)
??????????????????? {
??????????????????????? filePathName = Path.Combine(path, filename);
??????????????????????? Request.Files["fielLogoImg"].SaveAs(filePathName);
??????????????????????? cvModel.LogUrl = "/../Files/Web/" + CurrentUser.UName + "/" + filename;
??????????????????? }
??????????????????? else
??????????????????? {
??????????????????????? return Content("提示1:上傳圖片類型限制:" + ".gif|.bmp|.jpg|.jpeg|.png|.tif");
??????????????????? }
??????????????? }
??????????????? else
??????????????? {
??????????????????? return Content("提示4:圖片大小不超過100kb");
??????????????? }
??????????? }
??????????? else
??????????? {
??????????????? cvModel.LogUrl = "/../Files/Common/Web/Web1/Logo.png";//默認的圖片;
??????????? }
?
更多文章、技術交流、商務合作、聯系博主
微信掃碼或搜索:z360901061

微信掃一掃加我為好友
QQ號聯系: 360901061
您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對您有幫助就好】元
