Recommended: ASP tip example: ASP implementation of the most concise multi-query solution We often encounter multiple query problems, and long SQL statements often make monks confused. Especially when the client part fills in query conditions, it will be even more difficult to use ordinary methods. The following cleverly uses the identity of where 1=1 (
A simple ASP component-free upload class is sent out for everyone to see. Can do experiments!
| The following is the quoted content: <%@ language=javascript%> <% var self = Request.serverVariables(SCRIPT_NAME); if (Request.serverVariables(REQUEST_METHOD)==POST) { var oo = new uploadFile(); oo.path = myFile; //Storage path, empty means the current path, default is uploadFile oo.named = file; //Name method, date means naming with date, file means using file name itself, default is file oo.ext = all; //The extensions allowed to upload, all means that they are allowed, and the default is all oo.over = true; //Whether to overwrite when the same file name exists, the default is false oo.size = 1*1024*1024; //The maximum number of bytes is limited, the default is 1G oo.upload(); Response.write('<script type=text/javascript>location.replace(' self ')</script>'); } //ASP component-free upload class function uploadFile() { var bLen = Request.totalBytes; var bText = Request.binaryRead(bLen); var oo = Server.createObject(ADODB.Stream); oo.mode = 3; this.path = uploadFile; this.named = file; this.ext = all; this.over = false; this.size = 1*1024*1024*1024; //1GB //Upload file this.upload = function () { var o = this.getInfo(); if (o.size>this.size) { alert(the file is too large and cannot be uploaded!); return; } var f = this.getFileName(); var ext = f.replace(/^. /./,); if (this.ext!=all&&!new RegExp(this.ext.replace(/,/g,|),ig).test(ext)) { alert (currently, file uploads with ext extension are not supported!); return; } if (this.named==date) { f = new Date().toLocaleString().replace(//D/g,) . ext; } oo.open(); oo.type = 1; oo.write(o.bin); this.path = this.path.replace(/[^////]$/,$&/); var fso = Server.createObject(Scripting.FileSystemObject); if(this.path!=&&!fso.folderExists(Server.mapPath(this.path))) { fso.createFolder(Server.mapPath(this.path)); } try { oo.saveToFile(Server.mapPath(this.path f), this.over?2:1); alert(uploaded successfully!); } catch(e) { alert(sorry, this file already exists!); } oo.close(); delete(oo); } //Get binary and file bytes this.getInfo = function () { oo.open(); oo.type=1; oo.write(bText); oo.position = 0; oo.type=2; oo.charset=unicode; var gbCode=escape(oo.readText()).replace(/%u(..)(..)/g,%$2%$1); var sPos=gbCode.indexOf() 12; var sLength=bLen-(gbCode.substring(0,gbCode.indexOf()).length/3)-sPos/3-6; oo.close(); oo.open(); oo.type = 1; oo.write(bText); oo.position=sPos/3; var bFile=oo.read(sLength); oo.close(); return { bin:bFile, size:sLength }; } //Get file name this.getFileName = function () { oo.open(); oo.type = 2; oo.writeText(bText); oo.position = 0; oo.charset = gb2312; var fileName = oo.readText().match(/filename=/(. ?)//i)[1].split(//).slice(-1)[0]; oo.close(); return fileName; } function alert(msg) { Response.write('<script type=text/javascript>alert(' msg ');</script>'); } } %> <html> <head> <title>ASP component-free upload class</title> <meta http-equiv=content-Type content=text/html; charset=gb2312> </head> <body> <form action=<%=self%> method=post enctype=multipart/form-data onSubmit=return (this.upFile.value!='');> <input type=file name=upFile/> <input type=submit value=upload file/ </form> </body> </html> |
Share: 10 lines of code will let you say goodbye to the disconnect caused by Arp's evil deeds Many people are surfing the Internet together in the dormitory, and many people use ARP to do evil, which leads to keeping the Internet disconnection. I asked me if there was any solution, so I wrote the following vbs script. My classmate said that I would not get rid of the chat after using it. by