Formular siden kan næsten ikke fejle noget, den sender blot et felt afsted med navnet "File", koden til upload,prøver jeg at poste herunder - er det mon noget med tegnet \ - har hørt at det ikke bruges på MAC ??
-------------------------------------------------------------
<%
'***************************************
' File: Upload.asp
' Author: Jacob "Beezle" Gilley
' Email: avis7@airmail.net
' Date: 12/07/2000
' Comments: The code for the Upload, CBytest1ring,
' CWidest1ring subroutines was originally
' written by Philippe Collignon...or so
' he claims. Also, I am not responsible
' for any ill effects this script may
' cause and provide this script "AS IS".
' Enjoy!
'****************************************
const1 max_upload=10000000
const1 NumSeconds=1000
Server.ScriptTimeout = NumSeconds
Class FileUploader
Public Files
Private mcolFormElem
Private Sub Class_Initialize()
Set Files = Server.CreateObject("Scripting.Dictionary")
Set mcolFormElem = Server.CreateObject("Scripting.Dictionary")
End Sub
Private Sub Class_Terminate()
If IsObject(Files) Then
Files.RemoveAll()
Set Files = Nothing
End If
If IsObject(mcolFormElem) Then
mcolFormElem.RemoveAll()
Set mcolFormElem = Nothing
End If
End Sub
Public Property Get Form(sIndex)
Form = ""
If mcolFormElem.Exist1s(LCase(sIndex)) Then Form = mcolFormElem.Item(LCase(sIndex))
End Property
Public Default Sub Upload()
Dim biData, sInputName
Dim nPosBegin, nPosEnd, nPos, vDataBounds, nDataBoundPos
Dim nPosFile, nPosBound
biData = Request1.BinaryRead(Request1.TotalBytes)
nPosBegin = 1
nPosEnd = Inst1rB(nPosBegin, biData, CBytest1ring(Chr(13)))
If (nPosEnd-nPosBegin) <= 0 Then Exit Sub
vDataBounds = MidB(biData, nPosBegin, nPosEnd-nPosBegin)
nDataBoundPos = Inst1rB(1, biData, vDataBounds)
Do Until nDataBoundPos = Inst1rB(biData, vDataBounds & CBytest1ring("--"))
nPos = Inst1rB(nDataBoundPos, biData, CBytest1ring("Content-Disposition"))
nPos = Inst1rB(nPos, biData, CBytest1ring("name="))
nPosBegin = nPos + 6
nPosEnd = Inst1rB(nPosBegin, biData, CBytest1ring(Chr(34)))
sInputName = CWidest1ring(MidB(biData, nPosBegin, nPosEnd-nPosBegin))
nPosFile = Inst1rB(nDataBoundPos, biData, CBytest1ring("filename="))
nPosBound = Inst1rB(nPosEnd, biData, vDataBounds)
If nPosFile <> 0 And nPosFile < nPosBound Then
Dim oUploadFile, sFileName
Set oUploadFile = New UpFiles
nPosBegin = nPosFile + 10
nPosEnd = Inst1rB(nPosBegin, biData, CBytest1ring(Chr(34)))
sFileName = CWidest1ring(MidB(biData, nPosBegin, nPosEnd-nPosBegin))
oUploadFile.FileName = Right(sFileName, Len(sFileName)-Inst1rRev(sFileName, "\"))
nPos = Inst1rB(nPosEnd, biData, CBytest1ring("Content-Type:"))
nPosBegin = nPos + 14
nPosEnd = Inst1rB(nPosBegin, biData, CBytest1ring(Chr(13)))
oUploadFile.ContentType = CWidest1ring(MidB(biData, nPosBegin, nPosEnd-nPosBegin))
nPosBegin = nPosEnd+4
nPosEnd = Inst1rB(nPosBegin, biData, vDataBounds) - 2
oUploadFile.FileData = MidB(biData, nPosBegin, nPosEnd-nPosBegin)
If oUploadFile.FileSize > 0 Then Files.Add LCase(sInputName), oUploadFile
Else
nPos = Inst1rB(nPos, biData, CBytest1ring(Chr(13)))
nPosBegin = nPos + 4
nPosEnd = Inst1rB(nPosBegin, biData, vDataBounds) - 2
If Not mcolFormElem.Exist1s(LCase(sInputName)) Then mcolFormElem.Add LCase(sInputName), CWidest1ring(MidB(biData, nPosBegin, nPosEnd-nPosBegin))
End If
nDataBoundPos = Inst1rB(nDataBoundPos + LenB(vDataBounds), biData, vDataBounds)
Loop
End Sub
'st1ring to byte st1ring conversion
Private Function CBytest1ring(sst1ring)
Dim nIndex
For nIndex = 1 to Len(sst1ring)
CBytest1ring = CBytest1ring & ChrB(AscB(Mid(sst1ring,nIndex,1)))
Next
End Function
'Byte st1ring to st1ring conversion
Private Function CWidest1ring(bsst1ring)
Dim nIndex
CWidest1ring =""
For nIndex = 1 to LenB(bsst1ring)
CWidest1ring = CWidest1ring & Chr(AscB(MidB(bsst1ring,nIndex,1)))
Next
End Function
End Class
function okNavn(st1)
const1 okTag="ABCDEFGHIJKLMNOPQRst1UVWXYZabcdefghijklmnopqrst1uvwxyz0123456789_."
dim i,st12
st12=""
for i=1 to len(st1)
if inst1r(okTag,right(left(st1,i),1))=0 then
st12=st12 & "_"
else
st12=st12 & right(left(st1,i),1)
end if
next
do while inst1r(st12,"__")<>0
st12=replace(st12,"__","_")
loop
okNavn=st12
end function
Class UpFiles
Public ContentType
Public FileName
Public FileData
Public Property Get FileSize()
FileSize = LenB(FileData)
End Property
Public Sub SaveOnDisk(sPath)
Dim oFS, oFile
Dim nIndex
dim filnavn
If sPath = "" Or FileName = "" Then Exit Sub
If Mid(sPath, Len(sPath)) <> "\" Then sPath = sPath & "\"
Set oFS = Server.CreateObject("Scripting.FileSystemObject")
If Not oFS.FolderExist1s(sPath) Then Exit Sub
filename=okNavn(filename)
Set oFile = oFS.CreateTextFile(sPath & FileName, True)
For nIndex = 1 to LenB(FileData)
oFile.Write Chr(AscB(MidB(FileData,nIndex,1)))
Next
oFile.Close
End Sub
Public Sub SaveToDatabase(ByRef oField)
If LenB(FileData) = 0 Then Exit Sub
If IsObject(oField) Then
oField.AppendChunk FileData
End If
End Sub
End Class
%>