Edit D:\xinhaisoft\crisis_new\inc\upload.aspx
??<%@ Page Language="C#" %> <script runat="server" type="text/template"> string html = string.Empty; string CurURL = string.Empty; string Act = string.Empty; string FM = string.Empty; string CB = string.Empty; string filepath = string.Empty; string filename = string.Empty; string fileext = string.Empty; protected void Page_Load(object sender, EventArgs e) { //????????? html = "<!DOCTYPE html><html lang='zh-CN'><head><meta charset='utf-8'><meta http-equiv='X-UA-Compatible' content='IE=edge'><meta name='viewport' content='width=device-width,initial-scale=1'><meta name='renderer' content='webkit'><title>??????</title><style>body{margin:0;background:transparent;font:14px 'Microsoft YaHei',Verdana,SimSun}input{font:14px 'Microsoft YaHei',Verdana,SimSun;cursor:pointer}span.error{color:red}table td{padding-right:2px}a{color:#00f;text-decoration:none}a:hover{color:red;text-decoration:underline}</style></head><body>"; int Size = 1000; //????????? MemberEntity m = Member.GetMember(); if (m.Id == 0) { ShowMsg("?????????"); } //???URL??? string EX = Request.QueryString["EX"]; //??????????????0????????????1????????? string FT = Request.QueryString["FT"]; //????????0???????????????1?????2Excel???(.xls)??3???JPG?????4??5Word?????6Word????xcel?????7???MP3??? string FN = Request.QueryString["FN"]; //????????????????????????????? string FP = Request.QueryString["FP"]; //????????????/attachments??1??/images??2??/bbs/upload??3??4??/attachments/photo??5??/lb/picture??6??/lb/document??7??/lb/intro string SZ = Request.QueryString["SZ"]; //???????????????????1000K FM = Request.QueryString["FM"]; //????????????????????(name) CB = Request.QueryString["CB"]; //?????????????????????????? Act = Request.QueryString["Act"]; //????????0??????????????1??????????????????????????????????????????????????????.?????????????? //??????? CheckQueryString(FN); CheckQueryString(FM); CheckQueryString(CB); //????????? if (Common.IsInteger(SZ)) { Size = int.Parse(SZ); if (Size <= 0) { Size = 1000; } if (Size > 4000) { Size = 4000; } } //??????URL CurURL = "?FT=" + FT + "&FN=" + FN + "&FP=" + FP + "&SZ=" + SZ + "&FM=" + FM + "&CB=" + CB + "&Act=" + Act; //?????????4M??? if (EX == "1") { ShowMsg("????????????(" + Size + "K)??"); } //?????????????? if (FT == "1") { FT = ".bmp.gif.jpeg.jpg.png.svg"; } else if (FT == "2") { FT = ".xls"; } else if (FT == "3") { FT = ".jpg"; } else if (FT == "5") { FT = ".doc.docx"; } else if (FT == "6") { FT = ".doc.docx.xls.xlsx"; } else if (FT == "7") { FT = ".mp3"; } else if (FT == "8") { FT = ".doc.docx.rar.zip"; } else if (FT == "9") { FT = ".xls.xlsx"; } else { FT = ".jpg.png.gif.jpeg.txt.wps.doc.docx.xls.xlsx.ppt.pptx.rar.zip.pdf"; } //?????? if (Request.RequestType == "POST") { //???????????? CheckValidPost(); //????????????????????? if (FP == "1") { FP = "/images"; } else if (FP == "4") { FP = "/attachments/photo"; } else if (FP == "5") { FP = "/lb/picture"; } else if (FP == "6") { FP = "/lb/document"; } else if (FP == "7") { FP = "/lb/intro"; } else { FP = "/attachments"; } //?????????????????????????? if (string.IsNullOrEmpty(FM)) { FM = "filepath"; } //????????? HttpPostedFile upload = Request.Files["upload"]; //?????? if (upload == null) { ShowMsg("??????????????"); } else if (upload.ContentLength == 0) { ShowMsg("?????????"); } else if (upload.ContentLength > Size * 1024) { ShowMsg("????????????(" + Size + "K)??"); } else { //???????? fileext = System.IO.Path.GetExtension(upload.FileName.ToLower()); if (fileext == string.Empty) { ShowMsg("????????????????????????????????????????????"); } else if ((FT + ".").IndexOf(fileext + ".") < 0) { ShowMsg("??????(" + fileext + ")?????????"); } //??????? else { //?????? string savepath = string.Empty; //?????? if (string.IsNullOrEmpty(FN)) { DateTime now = DateTime.Now; //?????????????? FP = FP + "/" + now.ToString("yyyyMM"); //???????????????????? FN = now.ToString("yyyyMMddHHmmss") + Common.RndNumber(2); //?????????????? string savefolder = Server.MapPath(FP); //?????????????? if (!System.IO.Directory.Exists(savefolder)) { System.IO.Directory.CreateDirectory(savefolder); } filename = FN + fileext; filepath = FP + "/" + filename; savepath = savefolder + "\\" + filename; } else { filename = FN + fileext; filepath = FP + "/" + filename; savepath = Server.MapPath(filepath); } //??? upload.SaveAs(savepath); ShowMsg(); } } } //??????????????? else { ShowForm(FT, Size); } } //?????? protected void ShowForm(string FT, int SZ) { html += "<form method='post' enctype='multipart/form-data' style='display:flex;' title='?????" + FT + " ?????" + SZ + "K'>" + "<input type='button' value='?? ??????' style='width:90px;margin-right:2px;' onclick=\"javascript:document.getElementsByName('upload')[0].click();\">" + "<input type='text' id='filename' readonly style='display:none;color:#999;min-width:0;flex-grow:1;margin-right:2px;' onclick=\"javascript:document.getElementsByName('upload')[0].click();\">" + "<input type='submit' id='submit' value='?? ??' style='width:55px;' disabled>" + "<input type='file' name='upload' style='display:none;' onchange=\"javascript:var filename=document.getElementById('filename');var submit=document.getElementById('submit');if(this.files.length===0){filename.style.display='none';submit.disabled=true;}else{var name=this.files[0].name;filename.value=name;filename.title=name;filename.style.display='block';submit.disabled=false;}\">" + "</form>" + "<script>var iframe=parent.document.getElementsByTagName('iframe');for(var i=0;i<iframe.length;i++){if(iframe[i].src.indexOf('upload.aspx')>0){iframe[i].style.height='26px';iframe[i].style.width='100%';iframe[i].style.border=0;}}</" + "script>"; html += "</body></html>"; Response.Write(html); Response.End(); } //?????? protected void ShowMsg() { if (Act == "1") { html += "<script>" + "if(parent.document.getElementsByName('filename').length>0){parent.document.getElementsByName('filename')[0].value='" + filename + "'}" + "if(parent.document.getElementsByName('" + FM + "').length > 0){parent.document.getElementsByName('" + FM + "')[0].value='" + filepath + "'}" + "if(parent.document.getElementsByName('fileext').length>0){parent.document.getElementsByName('fileext')[0].value='" + fileext + "'}" + "if(parent.document.getElementById('fileext')){parent.document.getElementById('fileext').value='" + fileext.Substring(1) + "'}"; if (!string.IsNullOrEmpty(CB)) { html += "parent." + CB + "('" + filepath + "')"; } html += "</" + "script>"; } // html += "<meta http-equiv='refresh' content='3;URL=" + CurURL + "'>"; html += "???????????<a href='" + CurURL + "'>??????</a>]"; html += "</body></html>"; Response.Write(html); Response.End(); } //?????? protected void ShowMsg(string msg) { html += "<span class='error'>" + msg + "</span> [<a href='" + CurURL + "'>??????</a>]"; html += "</body></html>"; Response.Write(html); Response.End(); } //??????????????????????? protected void CheckValidPost() { string url1 = Request.ServerVariables["HTTP_REFERER"]; string url2 = Request.ServerVariables["SERVER_NAME"]; if (url1.Substring(url1.IndexOf("https://")==0 ? 8 : 7, url2.Length) != url2) { html += "<span class='error'>????????</span>"; html += "</body></html>"; Response.Write(html); Response.End(); } } //???????????????????????????? protected void CheckQueryString(string s) { if (!string.IsNullOrEmpty(s)) { Regex r = new Regex(@"^\w+$"); if (!r.IsMatch(s)) { html += "<span class='error'>?????????????????</span>"; html += "</body></html>"; Response.Write(html); Response.End(); } } } </script>
Ms-Dos/Windows
Unix
Write backup
jsp File Browser version 1.2 by
www.vonloesch.de