----------------------------- ±íµ¥ÌîдҳµÄÄÚÈÝ£º ----------------------------- <html> <head> <meta name="Author" content="Sander Duivestein"> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <meta name="GENERATOR" content="Microsoft FrontPage 4.0"> <meta name="ProgId" content="FrontPage.Editor.Document"> <title>½«±¾µØµÄÎļþÉÏÔØµ½Êý¾Ý¿â</title> </head> <body> <font size="2" size="2"><br> </font> <form name="frmUpload" method="post" enctype="multipart/form-data" action="Upload.asp"> <table cellspacing="0" cellpadding="0" width="490"> <tr> <td width="167"> <p align="right"><font size="2" size="2">ÇëÑ¡ÔñÎļþ£º</font></p> </td> <td width="319"><font size="2" size="2"><input type="file" name="vFileName"></font></td> </tr> <tr> <td align="right" width="167"><font size="2" size="2">Îļþ˵Ã÷1£º</font></td> <td width="319"><input name="shuoming" size="32" ></font></td> </tr> <tr> <td align="right" width="167"><font size="2" size="2">Îļþ˵Ã÷2£º</font></td> <td width="319"><input name="shuoming_2" size="32" onchange="isdate1(document.frmUpload.dengji)" </td> </tr> <td width="167"></td> <td width="319"> <p align="left"><font size="2" size="1"><input type="submit" style="background-image: url('images/back.jpg'); cursor: hand; font-sizd: smaller; left: 0px; width: 94; top: 5px; height: 25" value=" ÉÏ ÔØ " style="background-image: url('images/back.jpg'); cursor: hand; font-sizd: smaller; left: 0px; width: 94; top: 5px; height: 25" size="23" ></font></p> </td> <tr> <td colspan="2" align="right" width="487"></td> </tr> </table> </form> </body> </html> ---------------------------------- Upload.aspµÄÄÚÈÝ£º ---------------------------------- <% Response.Buffer = TRUE Response.Clear byteCount = Request.TotalBytes RequestBin = Request.BinaryRead(byteCount) 'response.binarywrite requestbin 'È¡µÃ±íµ¥µÄÈ«²¿ÄÚÈÝ ''''''''''''''''''''''''''''''''''''''''''''''''''''''' Dim UploadRequest Set UploadRequest = CreateObject("Scripting.Dictionary") ' UploadRequest½á¹¹½«ÓÃÀ´´æ·Å±íµ¥ PosBeg = 1 PosEnd = InstrB(PosBeg,RequestBin,StoB(chr(13))) boundary = MidB(RequestBin,PosBeg,PosEnd-PosBeg) 'Çó×ֶμäµÄ·Ö¸ô´®£¨¼´£º-----------------------------7d029e347d8 £© boundaryPos = InstrB(1,RequestBin,boundary) Do until (boundaryPos=InstrB(RequestBin,boundary & StoB("--"))) 'Members variable of objects are put in a dictionary object Dim UploadControl Set UploadControl = CreateObject("Scripting.Dictionary") 'Get an object name Pos = InstrB(BoundaryPos,RequestBin,StoB("Content-Disposition")) Pos = InstrB(Pos,RequestBin,StoB("name=")) PosBeg = Pos+6 PosEnd = InstrB(PosBeg,RequestBin,StoB(chr(34))) Name = BtoS(MidB(RequestBin,PosBeg,PosEnd-PosBeg)) PosFile = InstrB(BoundaryPos,RequestBin,StoB("filename=")) PosBound = InstrB(PosEnd,RequestBin,boundary) ' response.write "<hr>" ' response.write "name="&name&"<BR>" ' nameΪ±íµ¥ÏîµÄÃû×Ö 'Test if object is of file type If PosFile<>0 AND (PosFile<PosBound) Then PosBeg = PosFile + 10 PosEnd = InstrB(PosBeg,RequestBin,StoB(chr(34))) FileName = BtoS(MidB(RequestBin,PosBeg,PosEnd-PosBeg)) ' response.write "<BR>" ' response.write "filename="&filename&"<BR>" ' filenameΪȫ·¾¶ÎļþÃû£¨Èç¹ûÊÇÎļþÀàÐÍ»°£© UploadControl.Add "FileName", FileName Pos = InstrB(PosEnd,RequestBin,StoB("Content-Type:")) PosBeg = Pos+14 PosEnd = InstrB(PosBeg,RequestBin,StoB(chr(13))) ContentType = BtoS(MidB(RequestBin,PosBeg,PosEnd-PosBeg)) UploadControl.Add "ContentType",ContentType ' response.write "filetype="&ContentType&"<BR>" ' response.write "<BR>" PosBeg = PosEnd+4 PosEnd = InstrB(PosBeg,RequestBin,boundary)-2 Value = MidB(RequestBin,PosBeg,PosEnd-PosBeg) filesize = Posend - Posbeg UploadControl.Add "FileSize",filesize ' response.write "value=" ' response.binarywrite value ' response.write "<BR>" Else Pos = InstrB(Pos,RequestBin,StoB(chr(13))) PosBeg = Pos+4 PosEnd = InstrB(PosBeg,RequestBin,boundary)-2 Value = BtoS(MidB(RequestBin,PosBeg,PosEnd-PosBeg)) ' response.write "value="&value&"<BR>" ' valueΪ±íµ¥ÏîµÄÖµ£¬Èç¹ûΪÎļþÏÔòvalueΪһ³¤´®¶þ½øÖÆÂë End If UploadControl.Add "Value" , Value UploadRequest.Add name, UploadControl 'UploadRequestÔö¼ÓÒ»¸öKeyΪnameµÄÏ´ËÏîµÄvalueÈÔÊÇÒ»¸ödixtionary¶ÔÏó BoundaryPos=InstrB(BoundaryPos+LenB(boundary),RequestBin,boundary) Loop '''''''''''''''''''''''''''''''''''''''''''''''''''''''' contentType = UploadRequest.Item("vFileName").Item("ContentType") filesize = UploadRequest.Item("vFileName").Item("FileSize") filepathname = UploadRequest.Item("vFileName").Item("FileName") filename = Right(filepathname,Len(filepathname)-InstrRev(filepathname,"/")) filevalue = UploadRequest.Item("vFileName").Item("Value") shuoming = UploadRequest.Item("shuoming").Item("Value") shuoming_2 = UploadRequest.Item("shuoming_2").Item("Value") 'È¡³öǶÌ×µÄdictionary¶ÔÏóµÄÖµ,×¢ÒâdictionaryµÄKeyÇø·Ö´óСд£¡£¡£¡ ''''''''''''´¦ÀíÊý¾Ý¿â''''''''''''''''''''''''''''''''''''''''' set connGraph = server.CreateObject("ADODB.connection") connGraph.ConnectionString = Application("DNS") connGraph.Open Set DB = Server.CreateObject("ADODB.RecordSet") db.Open "SELECT * FROM t_recordnote where 1<>1",connGraph,1,3 db.addnew db("record").appendchunk filevalue db("shuoming") = shuoming db("shuoming_2") = shuoming_2 db("username") = session("username") db("filetype") = contentType db("time") = now() db("filename") = filename db("filesize") = filesize db.update db.close set db = nothing response.write "Îļþ"&filename&"ÉÏÔØ³É¹¦" ''''''''''''''''''''''''''''''''''''''''''''' Function StoB(varStr) str2bin = "" For i = 1 To Len(varstr) varchar = Mid(varstr, i, 1) varasc = Asc(varchar) ' asc¶ÔÖÐÎÄ×Ö·ûÇó³öÀ´µÄÖµ¿ÉÄÜΪ¸ºÊý£¬ ' ¼ÓÉÏ65536¾Í¿ÉÇó³öËüµÄÎÞ·ûºÅÊýÖµ ' -1ÔÚ»úÆ÷ÄÚÊÇÓò¹Âë±íʾµÄ0xffff, ' ÆäÎÞ·ûºÅֵΪ65535,65535=-1+65536 ' ÆäËû¸ºÊýÒÀ´ÎÀàÍÆ¡£ If varasc < 0 Then varasc = varasc + 65535 End If '¶ÔÖÐÎĵĴ¦Àí£º°ÑË«×Ö½ÚµÍλºÍ¸ßλ·Ö¿ª If varasc > 255 Then varlow = Left(Hex(Asc(varchar)), 2) varhigh = Right(Hex(Asc(varchar)), 2) str2bin = str2bin & ChrB("&H" & varlow) & ChrB("&H" & varhigh) Else str2bin = str2bin & ChrB(AscB(varchar)) End If Next StoB = str2bin End Function ''''''''''''''''''''''''''''''''''''''''''''''''''''' 'Byte string to string conversion Function BtoS(Binstr) 'ÖÐÎÄ×Ö·ûSkip±êÖ¾ skipflag = 0 strC = "" If Not IsNull(binstr) Then lnglen = LenB(binstr) For i = 1 To lnglen If skipflag = 0 Then tmpBin = MidB(binstr, i, 1) 'ÅжÏÊÇ·ñÖÐÎĵÄ×Ö·û If AscB(tmpBin) > 127 Then 'AscW»á°Ñ¶þ½øÖƵÄÖÐÎÄË«×Ö½Ú×Ö·û¸ßλºÍµÍλ·´×ª£¬ËùÒÔÒªÏȰÑÖÐÎĵĸߵÍλ·´×ª strC = strC & Chr(AscW(MidB(binstr, i + 1, 1) & tmpBin)) skipflag = 1 Else strC = strC & Chr(AscB(tmpBin)) End If Else skipflag = 0 End If Next End If BtoS = strC End Function '''''''''''''''''''''''''''''''''''''''''''''''''''''' %> ------------------------------ ±í½á¹¹£º ------------------------------ drop TABLE [t_RecordNote] CREATE TABLE [t_RecordNote] ( [RecordId] [int] IDENTITY (1, 1) NOT NULL , [filename] [varchar] (60) NULL , [filetype] [varchar] (40) NULL , [UserName] [varchar] (30) NULL , [Time] [datetime] NULL , [shuoming] [varchar] (200) NULL , [shuoming_2] [varchar] (200) NULL , [filesize] [int] NULL , [Record] [image] NULL , PRIMARY KEY CLUSTERED ( [RecordId] ) ON [PRIMARY] ) GO
|