日期:2014-05-18 浏览次数:20448 次
string test = Server.MapPath("ImageFiles/" + DateTime.Now.ToString("yyyy-MM-dd")); //用来生成文件夹 if (!Directory.Exists(test)) { Directory.CreateDirectory(test); } if (FileUpload1.PostedFile.FileName != "") { string imgname = FileUpload1.PostedFile.FileName; string imgType = imgname.Substring(imgname.LastIndexOf(".") + 1); string quanname =DateTime.Now.ToString("yyyyMMddHHmmss")+imgname.LastIndexOf("\\")+"."+imgType ; if ("gif" != imgType && "jpg" != imgType && "GIF" != imgType && "JPG" != imgType) { Response.Write("<script>alert('请选择gif,jpg格式的文件!');</script>"); return; } string imgurl = "ImageFiles/" + DateTime.Now.ToString("yyyy-MM-dd") + "/" + quanname; FileUpload1.PostedFile.SaveAs(Server.MapPath(imgurl));
------解决方案--------------------
什么叫如果啊?不明白
要上传LS的那几个都可以用的~