Timeout with upload function

Results 1 to 2 of 2

Thread: Timeout with upload function

  1. #1
    Join Date
    Dec 1969

    Default Timeout with upload function

    I got this asp upload function from the 4guys website and it works quite nicely. The only hitch is that my system times out if the file size is too big. My question is this: can I add a variable to the code to specify the timeout length? I&#039;m running PWS on a Win86SE machine, and don&#039;t have a way to control the script timeout otherwise.<BR>Here is the code as it stands. (I&#039;m not using the database functionality)<BR>Thanks in advance...<BR><BR>Class FileUploader<BR> Public Files<BR> Private mcolFormElem<BR><BR> Private Sub Class_Initialize()<BR> Set Files = Server.CreateObject("Scripting.Dictionary")<BR> Set mcolFormElem = Server.CreateObject("Scripting.Dictionary")<BR> End Sub<BR> <BR> Private Sub Class_Terminate()<BR> If IsObject(Files) Then<BR> Files.RemoveAll()<BR> Set Files = Nothing<BR> End If<BR> If IsObject(mcolFormElem) Then<BR> mcolFormElem.RemoveAll()<BR> Set mcolFormElem = Nothing<BR> End If<BR> End Sub<BR><BR> Public Property Get Form(sIndex)<BR> Form = ""<BR> If mcolFormElem.Exists(LCase(sIndex)) Then Form = mcolFormElem.Item(LCase(sIndex))<BR> End Property<BR><BR> Public Default Sub Upload()<BR> Dim biData, sInputName<BR> Dim nPosBegin, nPosEnd, nPos, vDataBounds, nDataBoundPos<BR> Dim nPosFile, nPosBound<BR><BR> biData = Request.BinaryRead(Request.TotalBytes)<BR> nPosBegin = 1<BR> nPosEnd = InstrB(nPosBegin, biData, CByteString(Chr(13)))<BR> <BR> If (nPosEnd-nPosBegin) &#060;= 0 Then Exit Sub<BR> <BR> vDataBounds = MidB(biData, nPosBegin, nPosEnd-nPosBegin)<BR> nDataBoundPos = InstrB(1, biData, vDataBounds)<BR> <BR> Do Until nDataBoundPos = InstrB(biData, vDataBounds & CByteString("--"))<BR> <BR> nPos = InstrB(nDataBoundPos, biData, CByteString("Content-Disposition"))<BR> nPos = InstrB(nPos, biData, CByteString("name="))<BR> nPosBegin = nPos + 6<BR> nPosEnd = InstrB(nPosBegin, biData, CByteString(Chr(34)))<BR> sInputName = CWideString(MidB(biData, nPosBegin, nPosEnd-nPosBegin))<BR> nPosFile = InstrB(nDataBoundPos, biData, CByteString("filename="))<BR> nPosBound = InstrB(nPosEnd, biData, vDataBounds)<BR> <BR> If nPosFile &#060;&#062; 0 And nPosFile &#060; nPosBound Then<BR> Dim oUploadFile, sFileName<BR> Set oUploadFile = New UploadedFile<BR> <BR> nPosBegin = nPosFile + 10<BR> nPosEnd = InstrB(nPosBegin, biData, CByteString(Chr(34)))<BR> sFileName = CWideString(MidB(biData, nPosBegin, nPosEnd-nPosBegin))<BR> oUploadFile.FileName = Right(sFileName, Len(sFileName)-InStrRev(sFileName, "\"))<BR><BR> nPos = InstrB(nPosEnd, biData, CByteString("Content-Type:"))<BR> nPosBegin = nPos + 14<BR> nPosEnd = InstrB(nPosBegin, biData, CByteString(Chr(13)))<BR> <BR> oUploadFile.ContentType = CWideString(MidB(biData, nPosBegin, nPosEnd-nPosBegin))<BR> <BR> nPosBegin = nPosEnd+4<BR> nPosEnd = InstrB(nPosBegin, biData, vDataBounds) - 2<BR> oUploadFile.FileData = MidB(biData, nPosBegin, nPosEnd-nPosBegin)<BR> <BR> If oUploadFile.FileSize &#062; 0 Then Files.Add LCase(sInputName), oUploadFile<BR> Else<BR> nPos = InstrB(nPos, biData, CByteString(Chr(13)))<BR> nPosBegin = nPos + 4<BR> nPosEnd = InstrB(nPosBegin, biData, vDataBounds) - 2<BR> If Not mcolFormElem.Exists(LCase(sInputName)) Then mcolFormElem.Add LCase(sInputName), CWideString(MidB(biData, nPosBegin, nPosEnd-nPosBegin))<BR> End If<BR><BR> nDataBoundPos = InstrB(nDataBoundPos + LenB(vDataBounds), biData, vDataBounds)<BR> Loop<BR> End Sub<BR><BR> &#039;String to byte string conversion<BR> Private Function CByteString(sString)<BR> Dim nIndex<BR> For nIndex = 1 to Len(sString)<BR> CByteString = CByteString & ChrB(AscB(Mid(sString,nIndex,1)))<BR> Next<BR> End Function<BR><BR> &#039;Byte string to string conversion<BR> Private Function CWideString(bsString)<BR> Dim nIndex<BR> CWideString =""<BR> For nIndex = 1 to LenB(bsString)<BR> CWideString = CWideString & Chr(AscB(MidB(bsString,nIndex,1))) <BR> Next<BR> End Function<BR>End Class<BR><BR>Class UploadedFile<BR> Public ContentType<BR> Public FileName<BR> Public FileData<BR> <BR> Public Property Get FileSize()<BR> FileSize = LenB(FileData)<BR> End Property<BR><BR> Public Sub SaveToDisk(sPath)<BR> Dim oFS, oFile<BR> Dim nIndex<BR> <BR> If sPath = "" Or FileName = "" Then Exit Sub<BR> If Mid(sPath, Len(sPath)) &#060;&#062; "\" Then sPath = sPath & "\"<BR> <BR> Set oFS = Server.CreateObject("Scripting.FileSystemObject")< BR> If Not oFS.FolderExists(sPath) Then Exit Sub<BR> <BR> Set oFile = oFS.CreateTextFile(sPath & FileName, True)<BR> <BR> For nIndex = 1 to LenB(FileData)<BR> oFile.Write Chr(AscB(MidB(FileData,nIndex,1)))<BR> Next<BR><BR> oFile.Close<BR> End Sub<BR> <BR> Public Sub SaveToDatabase(ByRef oField)<BR> If LenB(FileData) = 0 Then Exit Sub<BR> <BR> If IsObject(oField) Then<BR> oField.AppendChunk FileData<BR> End If<BR> End Sub<BR><BR>End Class<BR>%&#062;

  2. #2
    Join Date
    Dec 1969

    Default RE: Timeout with upload function

    At the top of the page, put in line line:<BR>Server.ScriptTimeout = nn<BR><BR>I&#039;m not sure what nn stands for -- it&#039;s either seconds or minutes or something. Look it up.<BR><BR>-Doug

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts