ASP no component uploaded

xiaoxiao2021-03-05  32

ASP no component uploads 1.upload.inc.asp

<% DIM OPFISTREAM CLASS UPFILE_CLASS DIM FORM, FILE, VERSION, ERR

Private sub class_initialize version = "No components Upload class Version v1.0" Err = -1 End Sub

Private sub class_terminate 'Clear Variables and Of Err

Public Sub GetData (RetSize) 'defines a variable Dim RequestBinDate, sSpace, bCrLf, sInfo, iInfoStart, iInfoEnd, tStream, iStart, oFileInfo Dim iFileSize, sFilePath, sFileType, sFormValue, sFileName Dim iFindStart, iFindEnd Dim iFormStart, iFormEnd, sFormName' code begins If Request.TotalBytes <1 THEN Err = 1 EXIT SUB End if ife = 1 EXIT SUB End If Request.totalbytes> Retsize Then Err = 2 EXIT SUB End If End If Set Form = Server.createObject ("scripting.dictionary") Form. CompareMode = 1 Set File = Server.CreateObject ( "Scripting.Dictionary") File.CompareMode = 1 Set tStream = Server.CreateObject ( "ADODB.Stream") Set oUpFileStream = Server.CreateObject ( "ADODB.Stream") oUpFileStream.Type = 1 oUpFileStream.Mode = 3 oUpFileStream.Open oUpFileStream.Write Request.BinaryRead (Request.TotalBytes) oUpFileStream.Position = 0 RequestBinDate = oUpFileStream.Read iFormEnd = oUpFileStream.Size bCrLf = ChrB (13) & ChrB (10) 'each made Separator SSCE = MIDB (Requestbindate, 1, INSTRB (1, RequestBindate, BCRLF) - ISTART = lenb (SSP ace) iFormStart = iStart 2 'exploded item Do iInfoEnd = InStrB (iFormStart, RequestBinDate, bCrLf & bCrLf) 3 tStream.Type = 1 tStream.Mode = 3 tStream.Open oUpFileStream.Position = iFormStart oUpFileStream.CopyTo tStream, iInfoEnd- iFormStart tStream.Position = 0 tStream.Type = 2 tStream.CharSet = "gb2312" sInfo = tStream.ReadText 'item name acquired form iFormStart = InStrB (iInfoEnd, RequestBinDate, sSpace) -1 iFindStart = InStr (22, sInfo, "name = "" ", 1) 6 ifindend = INSTR (ifindstart, sinfo," "" ", 1) sformname =

MID (SINFO, IFINDSTART) 'If it is file IF INSTR (45, Sinfo, "FileName =", ", 1)> 0 THEN SET OFLOLINFO = New fileInfo_class' get file attribute ifindstart = instr (ifindend, sinfo, "FileName =" ", 1) 10 ifindend = INSTR (ifindstart, sinfo," "", 1) sfilename = MID (SINFO, IFINDSTART, IFINDENDSTART) Ofileinfo.fileName = MID (SFileName, Instrrev (sfilename, "/") 1) ofileinfo.filepath = left (sfilename, "/") 1) ofileinfo.fileExt = MID (sfilename, INSTRREV (sfilename, ".") 1) ifindset = INSTR (ifindend) , sInfo, "Content-Type:", 1) 14 iFindEnd = InStr (iFindStart, sInfo, vbCr) oFileInfo.FileType = Mid (sinfo, iFindStart, iFindEnd-iFindStart) oFileInfo.FileStart = iInfoEnd oFileInfo.FileSize = iFormStart -iInfoEnd -2 oFileInfo.FormName = sFormName file.add sFormName, oFileInfo else 'form if the project tStream.Close tStream.Type = 1 tStream.Mode = 3 tStream.Open oUpFileStream.Position = iInfoEnd oUpFileStream.CopyTo tStream, iFormStart-iInfoEnd-2 TSTRE am.Position = 0 tStream.Type = 2 tStream.CharSet = "gb2312" sFormValue = tStream.ReadText If Form.Exists (sFormName) Then Form (sFormName) = Form (sFormName) & "," & sFormValue else form.Add sFormName SformValue End if end if tstream.close iformstart = iformstart iStart 2 'If the file ends, exiting Loop Until (IFORMSTART 2) = iformend requestbindate = "" SET TSTREAM = Nothing End Subend Class

'File attribute class Class FileInfo_ClassDim FormName, FileName, FilePath, FileSize, FileType, FileStart, FileExt' methods for saving files Public Function SaveToFile (Path) On Error Resume NextDim oFileStreamSet oFileStream = CreateObject ( "ADODB.Stream") = 1oFileStream oFileStream.Type. Mode = 3oFileStream.OpenoUpFileStream.Position = FileStartoUpFileStream.CopyTo oFileStream, FileSizeoFileStream.SaveToFile Path, 2oFileStream.CloseSet oFileStream = Nothingif Err.Number <> 0 thenSaveToFile = err.number & "**" & Err.descriptonelseSaveToFile = "ok" end ifEnd Function ' Obending file data public function filedateoupFileStream.position = filestRedate = OupfileStream.read (filesis) End Functionend Class%>

2. Handle the page after the user submitted (UPLOAD.ASP) file upload </ title> </ head> <body topmargin = "0" leftmargin = "0"> <table width = 100% border = 0 cellspacing = "0" cellpadding = "0"> <tr> <td class = Tablebody1 width = 100% height = 100%> <% DIM UPLOAD, FILE, FORMNAME, FORMPATH, FILENAME, FILEEXTDIM RANNUMCALL UPFILE () '=========== No component upload (UPLOAD_0) ============== ====== Sub upfile () set upload = new updile_class 'Establish upload object Upload.getdata (500 * 1024)' get uploaded data, here is 500 k</p> <p>If UPLOAD.ERR> 0 THENSELECT CASE UPLOAD.ERRCASE 1RESPONSE.WRITE "Please select the file you want to upload [<a href=# οnclick=history.go (1)" Case 2Response. " Write "picture size exceeds limit 500 k [<a href=# οnclick=history.go (1.) Re-Upload </A>]" End SelectExit SubelseFormPath = UPLOAD.FORM ("FilePath") 'file Save Directory, This directory must be readwritten if FormPath = "" "" = "rwdata /" end "after the directory (/) IF Right (FormPath, 1) <>" / "THEN FORMPATH = FormPath &" / "end if FOR Each Formname In Upload.file 'lists all uploaded files set file = upload.file (formname)' Generates a file object if file.filesize <100 TenResponse.write "please select the picture you want to upload [<a HREF = # οnclick = history.go (-1)> Re-upload </A>] "Response.Endend ifxt = LCASE (file.fileext) if checkfileext (fileext) = false" = false "file format is incorrect [<a href = # οnclick = history.go (-1)> Re-upload </a>] "Response.Endend IF</p> <p>'RandomizeranNum = int (90000 * rnd) 10000filename = formPath & year (now) & month (now) & day (now) & hour (now) & minute (now) & second (now) & ranNum & "." & FileExtif file.FileSize> 0 then' if FileSize > 0 Description Document Data Result = file.savetofile (server.mappath (filename)) 'Save File if Result = "OK" Theresponse.write Formname & "Upload Ok, Had Saved to" & FileName & "<br>" Elseresponse.write Formname & " "Upload Fail," & Result & "<br>" End IFEND IFSET FILE = NothingNextSet Upload = Nothingend IFEND SUB</p> <p>'Determines whether the file type qualified Private Function CheckFileExt (fileEXT) dim ForumuploadForumupload = "gif, jpg, bmp, jpeg" Forumupload = split (Forumupload, ",") for i = 0 to ubound (Forumupload) if lcase (fileEXT) = lcase (Trim (Forumupload (I))) ThencheckfileExt = trueXit FunctionElseCheckFileExt = false IfNextend Function%> </ TD> </ TR> </ table> </ body> </ html></p> <p>3.HTML form (UPLOAD.HTML) <! Doctype html public "- // w3c // DTD HTML 4.01 Transitional // En"> <html> <head> <meta http-equiv = "content-type" content = " TEXT / HTML; Charset = GB2312> <title> ASP No component upload </ title> </ head> <body> Please select the file you want to upload <form action = "upfile.asp" method = "post" eNCTYPE = " Multipart / form-data "name =" form1 "> <input type =" file "name =" file "> <!" name = "file"> <BR> <input TYPE = "file" name = "file"> <br> -> <input type = "submit" name = "submit" value = "submit"> </ form> </ body> </ html> <script type = "text / javascript"> google_ad_client = "pub-2624228443779279"; google_ad_width = 468; google_ad_height = 60; google_ad_format = "468x60_as"; google_ad_channel = ""; google_color_border = "FFFFFF"; google_color_bg = "FFFFFF"; google_color_link = "000000 "; google_color_url =" 000000 "; google_color_text =" 666666 "; </ script> <script src =" http://pagead2.googlesyndication.com/pagead/show_ads.js "type =" text / javascript "> </ script > name = "Google_ads_frame" marginwidth = "0" marginheight = "0" src = "http://pagead2.googleSynd Ication.com/pagead/ads?client=ca-pub-2624228443779279&dt=1114265161140&Format=468x60_as&ventput=468x60_as&Output=html&color_bg=fffffffffff&color_text=666666&color_link=000000&color_url=</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-32507.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="32507" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.043</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = 'CDJbzCmzcA_2BsgPg05pxIZWoOCUcSMBYqcJy1QGA3X73_2BMHduLZYzb4ifEDJX2KlhswJl0_2Fchk5RaIc9pmE97kg_3D_3D'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>