Avatar billede abband Nybegynder
22. oktober 2010 - 10:31 Der er 1 løsning

Illegal assignment: ‘IsFile'

Hej eksperter,

Jeg sidder og prøver at implementere et omskrevet SWFupload script til ASP, men kan ikke få det til at gemme filerne i mapper. Jeg får nedenstående fejlmeddelselse:

SWF DEBUG: Sun ONE ASP VBScript runtime error ‘800a01f5′
SWF DEBUG:
SWF DEBUG: Illegal assignment: ‘IsFile'
SWF DEBUG:
SWF DEBUG: class/upload.asp, line 90

Koden ser således ud:

Class overrUpload

    Private m_uploadData        ' As Scripting.Dictionary
    Private m_constIsFile        ' As Integer
    Private m_constValue        ' As Integer
    Private m_constFilename        ' As Integer
    Private m_constContentType    ' As Integer
   
    '## -- --------------------------------------------------------------------------------------------------
    '## -- PUBLIC METHODS
    '## -- --------------------------------------------------------------------------------------------------
    '## -- added by.........Patrik Berggren
    '##    date added.......September 5, 2003
    Public Default Property Get Form(ByVal sItem)
        sItem = LCase(sItem)
        Dim i
        Dim objID        ' As FileData
           
        '## -- check if the item exists in the collection --
        If m_uploadData.Exists(sItem) Then
            '## -- item found in collection. proceed --
            Dim o    ' As Variant
            '## -- get item --
            o = m_uploadData.Item(sItem)
            If (o(m_constIsFile)) Then
                Set objID = New FileData
                    With objID
                        .IsFiles = o(m_constIsFile)
                        .Value = o(m_constValue)
                        .Filename = o(m_constFilename)
                        .ContentType = o(m_constContentType)
                   
                        If (Len("" & .Filename) = 0) Then .IsFile = False
                       
                    End With
                    Set Form = objID
                Set objID = Nothing
            Else
                '## -- no file exists. just return value --
                Form = o(m_constValue)
            End If
        Else
            '## -- item not found in the collection. print out error message and stop executing the script --
            Response.Write("ERROR: Couldn´t find the form-field - <em>" & sItem & "</em> - in the collection.")
            Response.End
        End If
    End Property
   
    '## -- --------------------------------------------------------------------------------------------------
    '## -- PRIVATE METHODS
    '## -- --------------------------------------------------------------------------------------------------

    '## -- set default values --
    Private Sub Class_Initialize()
        m_constIsFile = 0
        m_constValue = 1
        m_constFilename = 2
        m_constContentType = 3
        Set m_uploadData = Server.CreateObject("Scripting.Dictionary")   
        Call ExtractFormData
    End Sub

    Private Sub ExtractFormData()
        Dim varyItem(3)        ' as Variant
        Dim byteCount        ' As Integer
        Dim requestBin        ' As Integer
        Dim posBeg            ' As Integer
        Dim posEnd            ' As Integer
        Dim boundary        ' As Binary
        Dim boundaryPos        ' As Integer
        Dim UploadControl    '## -- replace with array --
        Dim pos                ' As Integer
        Dim Name            '## -- remove. save to array --
        Dim posFile            ' As Integer
        Dim posBound        ' As Integer
        Dim Value            '## -- remove. save to array --
        Dim Filename        '## -- remove. save to array --
        Dim ContentType        '## -- remove. save to array --
       
        ByteCount = Request.TotalBytes
        RequestBin = Request.BinaryRead(byteCount)
       
            '# Begin boundary
            PosBeg = 1
            'PosEnd = InstrB(PosBeg, RequestBin, getByteString(chr(13)))
            PosEnd = InstrB(PosBeg, RequestBin, GetBytesFromString(chr(13)))
            boundary = MidB(RequestBin, PosBeg, PosEnd - PosBeg)
            boundaryPos = InstrB(1, RequestBin, boundary)
            'Get all data inside the boundaries
            Do until (boundaryPos = InstrB(RequestBin, boundary & GetBytesFromString("--")))
                'Members variable of objects are put in a dictionary object
                Set UploadControl = CreateObject("Scripting.Dictionary")
                'Get an object name
                Pos = InstrB(BoundaryPos, RequestBin, GetBytesFromString("Content-Disposition"))
                Pos = InstrB(Pos, RequestBin, GetBytesFromString("name="))
                PosBeg = Pos + 6
                PosEnd = InstrB(PosBeg, RequestBin, GetBytesFromString(chr(34)))
                Name = GetStringFromBytes(MidB(RequestBin, PosBeg, PosEnd - PosBeg))
                Name = LCase(Name)
                PosFile = InstrB(BoundaryPos, RequestBin, GetBytesFromString("filename="))
                PosBound = InstrB(PosEnd, RequestBin, boundary)
                'Test if object is of file type
                If PosFile <> 0 AND (PosFile < PosBound) Then
                    varyItem(m_constIsFile) = True
                    'Get Filename, content-type and content of file
                    PosBeg = PosFile + 10
                    PosEnd = InstrB(PosBeg, RequestBin, GetBytesFromString(chr(34)))
                    FileName = GetStringFromBytes(MidB(RequestBin, PosBeg, PosEnd - PosBeg))
                    'Add filename to dictionary object
                    varyItem(m_constFilename) = FileName
                   
                    Pos = InstrB(PosEnd, RequestBin, GetBytesFromString("Content-Type:"))
                    PosBeg = Pos+14
                    PosEnd = InstrB(PosBeg, RequestBin, GetBytesFromString(chr(13)))
                    'Add content-type to dictionary object
                    ContentType = GetStringFromBytes(MidB(RequestBin, PosBeg, PosEnd - PosBeg))
                    varyItem(m_constContentType) = ContentType
                   
                    'Get content of object
                    PosBeg = PosEnd + 4
                    PosEnd = InstrB(PosBeg, RequestBin, boundary)-2
                    Value = MidB(RequestBin, PosBeg, PosEnd - PosBeg)
                    varyItem(m_constValue) = Value
                Else
                    varyItem(m_constIsFile) = False
                    'Get content of object
                    Pos = InstrB(Pos, RequestBin, GetBytesFromString(chr(13)))
                    PosBeg = Pos + 4
                    PosEnd = InstrB(PosBeg, RequestBin, boundary)-2
                    Value = GetStringFromBytes(MidB(RequestBin, PosBeg, PosEnd - PosBeg))
                    varyItem(m_constValue) = Value
                End If
               
                'Add item-data array to dictionary
                m_uploadData.Add Name, varyItem
               
                'Loop to next object
                BoundaryPos=InstrB(BoundaryPos + LenB(boundary), RequestBin, boundary)
            Loop
    End Sub
   
    Private Function GetBytesFromString(sValue)
        Dim i
        Dim intLength
        Dim strChar
        Dim outPut
       
        intLength = Len("" & sValue)
       
        For i = 1 TO intLength
            strChar = Mid(sValue,i,1)
            outPut = outPut & ChrB(AscB(strChar))
        Next
        GetBytesfromstring = outPut
    End Function
   
    Private Function GetStringFromBytes(binString)
        Dim i
        Dim intLength
        Dim outPut
        outPut = ""
        intLength = LenB(binString)
        For i = 1 TO intLength
            outPut = outPut & Chr(AscB(MidB(binString, i, 1)))
        Next
        GetStringFromBytes = outPut
    End Function
   
    '## -- assign default settings --
    Private Sub Class_Terminate()
        '## -- clean up --
        Set m_uploadData = Nothing
    End Sub
End Class

Nogen der kan hjælpe og eventuelt fortælle, hvad der går galt?
Avatar billede abband Nybegynder
22. oktober 2010 - 11:07 #1
Oprettet i forkert kategori, beklager...
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester