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(""); return null; } } else { Response.Write(""); return null; }
希望采纳