Subject: Uploading Files
Posted By: tbriers Post Date: 8/22/2003 7:04:06 AM
Hi,
I am creating a form which should upload a file to the server but the code gets stuck at a certain point.
The code from the form is:

<form method=post enctype="multipart/form-data" action="CompanyFolderTab.asp" target="filelist">
    <tr>
        <td class=header bordercolor="#315182" colspan=2>
            Nieuw of aangepast bestand publiceren
        </td>
    </tr>
    <tr>
        <td>Bestand&nbsp</td>
        <td><input type="file" name="fileSource"></td>
    </tr>
    <tr>
        <td width=1></td>
        <td><input type="submit" value="Publiceren"></td>
    </tr>
    </form>

In the CompanyFolderTab.asp the Upload.inc is included and the function GetFields is called

This function looks like this  (The logfile exists and works)

Function GetFields(UploadSizeLimit,logfile)
  logfile.WriteLine(" Function GetFields.  UploadSizeLimit= " & UploadSizeLimit)
  Dim Result
  Set Result = Nothing
  'Request method must be "POST"
  If Request.ServerVariables("REQUEST_METHOD") <> "POST" Then
    logfile.WriteLine("Request method is " & Request.ServerVariables("REQUEST_METHOD") & ".")
    Err.Raise 51, "GetUpload", "Request method is """ & Request.ServerVariables("REQUEST_METHOD") & """.  Dit moet ""post"" zijn."
  Else

    'read Content-Type
    Dim CT
    CT = Request.ServerVariables("HTTP_Content_Type")
    logfile.WriteLine("Header = " & CT)
    ' Content-Type header must be "multipart/form-data"
    If LCase(Left(CT, 19)) <> "multipart/form-data" Then
      logfile.WriteLine("Header is niet multipart/form-data maar is :" & CT)
      Err.Raise 51, "GetUpload", "Content-type is """ & CT & """.  Dit moet ""multipart/form-data"" zijn."
    Else
      Dim Boundary, PosB, PosE

      'Get the boundary and length from Content-Type header
      PosB = InStr(LCase(CT), "boundary=")
      If PosB > 0 Then Boundary = Mid(CT, PosB + 9)

      '****** Error of IE5.01 - doubles http header
      PosB = InStr(LCase(CT), "boundary=")
      If PosB > 0 then 'Patch for the IE error
        PosB = InStr(Boundary, ",")
        If PosB > 0 Then Boundary = Left(Boundary, PosB - 1)
      end if
      logfile.WriteLine("PosB : " & PosB & "  Boundary : " & Boundary)
      '****** Error of IE5.01 - doubles http header

      Dim Length
      Length = CLng(Request.ServerVariables("HTTP_Content_Length")) 'Get Content-Length header
      logfile.WriteLine("Length = " & Length)
      If "" & UploadSizeLimit <> "" Then
        UploadSizeLimit = CLng(UploadSizeLimit)
        If Length > UploadSizeLimit Then
'          Request.BinaryRead (Length)
            logfile.WriteLine("Uploadsize is to large.")
          Err.Raise 2, "GetUpload", "Upload (" & FormatNumber(Length, 0) & " B) is groter dan toegelaten (" & FormatNumber(UploadSizeLimit, 0) & " B)"
          Exit Function
        End If
      End If
      
      If Length > 0 And Boundary <> "" Then 'Are there required informations about upload ?
        Boundary = "--" & Boundary
        logfile.WriteLine("Length = " & Length & " - - Boundary : " & Boundary)
        logfile.WriteLine("Why do you stop here?")
        Dim fileData
        fileData = "dude this is going bad"
        logfile.WriteLine("Dim Binary : " & fileData )
        'Reads binary data from client
         fileData = Request.BinaryRead(Length)   ///////This is were it goes wrong     
         logfile.WriteLine("After binary read")
        
        'Retrieves the upload fields from binary data
        Set Result = SeparateFields(fileData, Boundary)
        logfile.WriteLine("Result = " & Result)
        fileData = Empty 'Clear variables
      Else
      logfile.WriteLine("Http contents is empty")
        Err.Raise 51, "GetUpload", "HTTP inhoud is leeg."
      End If
    End If
  End If
  Set GetFields = Result
End Function


I know it is a lot of code but near the end there is the line:
fileData = Request.BinaryRead(Length)
This is were it goes wrong.  The script will not go past this line.
(Length = TotalBytes)

any suggestions to how I can get this to work.

Greetz

Tom.
Reply By: tbriers Reply Date: 8/22/2003 7:45:40 AM
By the way:

The Error message is


Request object error 'ASP 0104 : 80004005'

Operation not Allowed

/includes/Upload.inc, line 74

and line 74 is fileData = Request.BinaryRead(Length)

Greetz

Tom
Reply By: uit Reply Date: 8/22/2003 10:22:31 AM
Watch that you dont have anti-virus software on that IIS server which prevents script processing - that will hold it up.
Reply By: tbriers Reply Date: 8/25/2003 3:11:59 AM
I have found that the error doesn't occur with small files.

< 100 K

But once a file is a bit larger but still within the limits I set I get the error.

How does this come and how do I solve this.

To Recap:  the upload works but not with larger files.

Any suggestions.

Greetz

Tom.
Reply By: tbriers Reply Date: 8/25/2003 3:26:18 AM
Well, my day is saved thanks to the following post I found on another forum.

For all the persons who have trouble with up and download in asp with iis 6.0 here is the solutions that helped me

IIS 6.0: upload and download issues
If any of you are having issues with uploads and downloads with Web Explorer Free and are running IIS 6.0, try these solutions first: open up the file "metabase.xml" with notepad...should be located in C:\windows\sytem32\inetserv. Find the variable named "AspBufferingLimit" and change it to something greater than what is there. By default this is set to around 4 megs. By changing this variable you are increasing the max size of ASP response buffer, thus letting you download files greater than 4 megs using WexFree. For uploading files greater than this ammount, look for the variable named "AspMaxRequestEntityAllowed" and change it to the desired size. And there you have it. By increasing the number of these variables, you can controll the size of uploads and downloads (respectively) while using Web Explorer Free. Hope this helps. -Peace-


Enjoy

Greetz

Tom.
Reply By: carasage Reply Date: 10/26/2003 10:49:40 PM
i can not get metabase.xml to save when editing in notepad...

how did u manage to edit it?

Reply By: carasage Reply Date: 10/26/2003 11:21:43 PM
quote:
Originally posted by tbriers

Well, my day is saved thanks to the following post I found on another forum.

For all the persons who have trouble with up and download in asp with iis 6.0 here is the solutions that helped me

IIS 6.0: upload and download issues
If any of you are having issues with uploads and downloads with Web Explorer Free and are running IIS 6.0, try these solutions first: open up the file "metabase.xml" with notepad...should be located in C:\windows\sytem32\inetserv. Find the variable named "AspBufferingLimit" and change it to something greater than what is there. By default this is set to around 4 megs. By changing this variable you are increasing the max size of ASP response buffer, thus letting you download files greater than 4 megs using WexFree. For uploading files greater than this ammount, look for the variable named "AspMaxRequestEntityAllowed" and change it to the desired size. And there you have it. By increasing the number of these variables, you can controll the size of uploads and downloads (respectively) while using Web Explorer Free. Hope this helps. -Peace-


Enjoy

Greetz

Tom.



I tried this... unfortunately didnt help for the download via ado.stream..

the save to dialogue doesnt even pop up when i changed the 4MB limit to a 40MB limit.



Reply By: tbriers Reply Date: 10/27/2003 3:55:35 PM
The Save Dialogue box doesn't have anything to do with the limits set in the xml file.

When this does not show there is probably something wrong with your Form Code.

The Errors that have something to do with the upload limits occur on the server side and a dialogue box happens on the client side.

Regards, Tom.

Go to topic 5746

Return to index page 1018
Return to index page 1017
Return to index page 1016
Return to index page 1015
Return to index page 1014
Return to index page 1013
Return to index page 1012
Return to index page 1011
Return to index page 1010
Return to index page 1009