Det virker ikke....
tjek her:
www.dlaursen.dk/test/upload1.aspDen uploader godt nok billedefilen til mappen, men ikke noget tilføjet i databasen....
se koder nedenunder
----------------------------------------------------------------------
<%@ LANGUAGE="VBScript" %>
<%
Option Explicit
Response.Expires = -1
Response.Buffer = True
Response.Clear
Dim cdpBinaryData,cdpBoundary,cdpBoundPosition,cdpCharacter,cdpContentType,cdpCount,cdpDicUploadControl,cdpDicUploadRequest,cdpEndPosition,cdpFile,cdpFileName,cdpFilePath,cdpFilePosition,cdpFileSize,cdpFSO,cdpI,cdpName,cdpPosition,cdpPositionBoundary,cdpStartPosition,cdpTotalBytes,cdpValue
cdpTotalBytes = Request.TotalBytes
cdpBinaryData = Request.BinaryRead(cdpTotalBytes)
Set cdpDicUploadRequest = CreateObject("Scripting.Dictionary")
cdpUploadRoutine cdpBinaryData
cdpContentType = cdpDicUploadRequest("theFile")("cdpContentType")
cdpFilePath = cdpDicUploadRequest("theFile")("cdpFileName")
cdpFileName = Right(cdpFilePath,Len(cdpFilePath)-InstrRev(cdpFilePath,"\"))
If Not cdpFileName = "" Then
cdpValue = cdpDicUploadRequest("theFile")("cdpValue")
Set cdpFSO = Server.CreateObject("Scripting.FileSystemObject")
Set cdpFile = cdpFSO.CreateTextFile(Server.mappath("pics/" & cdpFileName))
For cdpI = 1 To LenB(cdpValue)
cdpFile.Write Chr(AscB(MidB(cdpValue,cdpI,1)))
Next
set rs = server.createObject("adodb.connection")
sql = "insert into pictures(pic) values('"&cdpFileName&"')"
conn = "DRIVER={Microsoft Access Driver (*.mdb)}; "
conn = conn & "DBQ=" & server.mappath("db.mdb")
rs.open conn
set rs = rs.execute(sql)
cdpFile.Close
Set cdpFile = Nothing
Sub cdpUploadRoutine(cdpBinaryData)
cdpStartPosition = 1
cdpEndPosition = InstrB(cdpStartPosition,cdpBinaryData,getByteString(Chr(13)))
cdpBoundary = MidB(cdpBinaryData,cdpStartPosition,cdpEndPosition-cdpStartPosition)
cdpPositionBoundary = InstrB(1,cdpBinaryData,cdpBoundary)
Do until (cdpPositionBoundary=InstrB(cdpBinaryData,cdpBoundary & getByteString("--")))
Set cdpDicUploadControl = CreateObject("Scripting.Dictionary")
cdpPosition = InstrB(cdpPositionBoundary,cdpBinaryData,getByteString("Content-Disposition"))
cdpPosition = InstrB(cdpPosition,cdpBinaryData,getByteString("name="))
cdpStartPosition = cdpPosition + 6
cdpEndPosition = InstrB(cdpStartPosition,cdpBinaryData,getByteString(Chr(34)))
cdpName = getString(MidB(cdpBinaryData,cdpStartPosition,cdpEndPosition-cdpStartPosition))
cdpFilePosition = InstrB(cdpPositionBoundary,cdpBinaryData,getByteString("filename="))
cdpBoundPosition = InstrB(cdpEndPosition,cdpBinaryData,cdpBoundary)
If cdpFilePosition <> 0 And (cdpFilePosition<cdpBoundPosition) Then
cdpStartPosition = cdpFilePosition + 10
cdpEndPosition = InstrB(cdpStartPosition,cdpBinaryData,getByteString(Chr(34)))
cdpFileName = getString(MidB(cdpBinaryData,cdpStartPosition,cdpEndPosition-cdpStartPosition))
cdpDicUploadControl.Add "cdpFileName", cdpFileName
cdpPosition = InstrB(cdpEndPosition,cdpBinaryData,getByteString("Content-Type:"))
cdpStartPosition = cdpPosition + 14
cdpEndPosition = InstrB(cdpStartPosition,cdpBinaryData,getByteString(Chr(13)))
cdpContentType = getString(MidB(cdpBinaryData,cdpStartPosition,cdpEndPosition-cdpStartPosition))
cdpDicUploadControl.Add "cdpContentType",cdpContentType
cdpStartPosition = cdpEndPosition + 4
cdpEndPosition = InstrB(cdpStartPosition,cdpBinaryData,cdpBoundary) - 2
cdpValue = MidB(cdpBinaryData,cdpStartPosition,cdpEndPosition-cdpStartPosition)
Else
cdpPosition = InstrB(cdpPosition,cdpBinaryData,getByteString(Chr(13)))
cdpStartPosition = cdpPosition + 4
cdpEndPosition = InstrB(cdpStartPosition,cdpBinaryData,cdpBoundary) - 2
cdpValue = getString(MidB(cdpBinaryData,cdpStartPosition,cdpEndPosition-cdpStartPosition))
End If
cdpDicUploadControl.Add "cdpValue" , cdpValue
cdpDicUploadRequest.Add cdpName, cdpDicUploadControl
cdpPositionBoundary=InstrB(cdpPositionBoundary+LenB(cdpBoundary),cdpBinaryData,cdpBoundary)
Loop
End Sub
Function getByteString(StringStr)
For cdpI = 1 To Len(StringStr)
cdpCharacter = Mid(StringStr,cdpI,1)
getByteString = getByteString & chrB(AscB(cdpCharacter))
Next
End Function
Function getString(cdpBinaryString)
getString = ""
For cdpCount = 1 To LenB(cdpBinaryString)
getString = getString & Chr(AscB(MidB(cdpBinaryString,cdpCount,1)))
Next
End Function
cdpFileSize = cdpTotalBytes / 1024
cdpFileSize = Round(cdpFileSize, 2)
Response.Write("<title>The file " & cdpFileName & " was successfully uploaded! - Size: " & cdpFileSize & "</title>")
Response.Write(cdpFileName & " Uploaded successfully! Size: " & cdpFileSize & " kb.<br />")
Response.Write("<center><a href='upload1.asp'>Videre</a></center>")
End If
%>