View Single Post
  #26 (permalink)  
Old March 10th, 2007, 10:56 AM
grstad grstad is offline
Friend of Wrox
Join Date: May 2005
Location: , , Norway.
Posts: 189
Thanks: 0
Thanked 0 Times in 0 Posts

... yes, my web app does work. The upload-code works. There are no errors. But I do not wish any clients to be able to upload any harmful files to the webserver.

The code is called by using

Why do you think moving the validation from the disk based method to the database method would be enough?
      I thaught that there were no ".jpeg" or ".gif" in the binary-file text to be recognized!

What aboat;

    Public Sub SaveToDisk(sPath)
        Dim oFS, oFile
        Dim nIndex

        If sPath = "" Or FileName = "" Then Exit Sub
        If Mid(sPath, Len(sPath)) <> "\" Then sPath = sPath & "\"

        Set oFS = Server.CreateObject("Scripting.FileSystemObject")
        If Not oFS.FolderExists(sPath) Then Exit Sub

        Set oFile = oFS.CreateTextFile(sPath & FileName, True)

        For nIndex = 1 to LenB(FileData)
            oFile.Write Chr(AscB(MidB(FileData,nIndex,1)))

    End Sub

    Public Sub SaveToDatabase(ByRef oField)
             If LenB(FileData) = 0 Or Right(FileData) <> .gif Then Exit Sub
       If IsObject(oField) Then
            oField.AppendChunk FileData
        End If
    End Sub

Reply With Quote