展开全部
savefilename = Server.MapPath("../GoodsView/upfile")+"/" + filename1; FileInfo f_name = new FileInfo(File1.PostedFile.FileName); string s1 = f_name.Extension.ToString(); //取得后缀名 if( s1 == ".jpg" || s1 == ".gif" || s1 == ".JPG" || s1 == ".GIF") { if ( File1.PostedFile.ContentLength < 140000 ) { File1.PostedFile.SaveAs(Server.MapPath("../GoodsView/upfile")+"/" + filename1 + ".jpg"); //saveSQLStr = "GoodsView/upfile/" + filename1; saveSQLStr = filename1; return saveSQLStr; } else { Response.Write("<script language=javascript>alert('图片大小不能超过140k');</script>"); return null; } } else { Response.Write("<script language=javascript>alert('图片格式只能为jpg或gif');</script>"); return null; }
希望采纳
希望采纳
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询