473,785 Members | 2,811 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Timeout? in asp script upload

Hello,

I got the following scripts to upload files to my directories

I call insert.htm

Browse for a file, then click 'submit'

It works for small files, and for a small .mdb (access file)

But for any larger file, it quits and give me 'page not found'

Is there some kind of timeout I can set?

Note: insert.htm calls insert.asp, call load.asp

Thanks:

Insert.asp:

<!-- insert.htm -->
<html>
<head>
<title>File Uploading with ASP</title>
<style>
body, input { font-family:verdana, arial; font-size:10pt; }
</style>
</head>
<body>
<p align="center">
<b>File Uploading with ASP</b><br>
<a href="show.asp" >To see uploaded data click here</a>
</p>

<table border="0" align="center">
<tr>
<form method="POST" enctype="multip art/form-data" action="Insert. asp">
<td>Name :</td><td>
<input type="text" name="name" size="40"></td></tr>
<td>File :</td><td>
<input type="file" name="file" size="40"></td></tr>
<td> </td><td>
<input type="submit" value="Submit"> </td></tr>
</form>
</tr>
</table>

</body>
</html>
insert.asp:

<% ' Insert.asp %>
<!--#include file="Loader.as p"-->
<%

Response.Buffer = True

' load object
Dim load
Set load = new Loader

' calling initialize method
load.initialize
response.write "<br>hi1122 "

' File binary data
Dim fileData
fileData = load.getFileDat a("file")
' File name
Dim fileName
fileName = LCase(load.getF ileName("file") )
' File path
Dim filePath
filePath = load.getFilePat h("file")
' File path complete
Dim filePathComplet e
filePathComplet e = load.getFilePat hComplete("file ")
' File size
Dim fileSize
fileSize = load.getFileSiz e("file")
' File size translated
Dim fileSizeTransla ted
fileSizeTransla ted = load.getFileSiz eTranslated("fi le")
' Content Type
Dim contentType
contentType = load.getContent Type("file")
' No. of Form elements
Dim countElements
countElements = load.Count
' Value of text input field "name"
Dim nameInput
nameInput = load.getValue(" name")
' Path where file will be uploaded
Dim pathToFile
' pathToFile = Server.mapPath( "uploaded/") & "\" & fileName
pathToFile = Server.mapPath( "businessse arch/") & "\" & fileName
' Uploading file data
response.write "<br>hi1122 33"
response.write "<br> " & pathtofile
'response.end
Dim fileUploaded
fileUploaded = load.saveToFile ("file", pathToFile)
'response.write "<br>hi11223344 4"
'response.end
' destroying load object
Set load = Nothing
%>

<html>
<head>
<title>File Uploading with ASP</title>
<style>
body, input, td { font-family:verdana, arial; font-size:10pt; }
</style>
</head>
<body>
<p align="center">
<b>File Uploading with ASP</b><br>
<a href="show.asp" >To see uploaded files click here</a>
</p>

<table width="700" border="1" align="center">
<tr>
<td>File Name</td><td><%= fileName %></td>
</tr><tr>
<td>File Path</td><td><%= filePath %></td>
</tr><tr>
<td>File Path Complete</td><td><%= filePathComplet e %></td>
</tr><tr>
<td>File Size</td><td><%= fileSize %></td>
</tr><tr>
<td>File Size Translated</td><td><%= fileSizeTransla ted %></td>
</tr><tr>
<td>Content Type</td><td><%= contentType %></td>
</tr><tr>
<td>No. of Form Elements</td><td><%= countElements %></td>
</tr><tr>
<td>Name</td><td><%= nameInput %></td>
</tr>
</table><br><br>

<p style="padding-left:220;">
<%
If fileUploaded = True Then
Response.Write fileName & " data uploaded..."
Else
Response.Write "<font color=""red"">F ile could not be uploaded..."
Response.Write "</font>"
Response.Write "<br>Please select a file before hitting the
'Submit'"
Response.Write " button."
End If
%>
</p>

<br>
<table border="0" align="center">
<tr>
<form method="POST" enctype="multip art/form-data" action="Insert. asp">
<td>Name :</td><td>
<input type="text" name="name" size="40" value="<%= nameInput %>">
</td></tr>
<td>File :</td><td>
<input type="file" name="file" size="40"></td></tr>
<td> </td><td>
<input type="submit" value="Submit"> </td></tr>
</form>
</tr>
</table>

</body>
</html>
loader.asp:

<%
' -- Loader.asp --
' -- version 1.5.2
' -- last updated 12/5/2002
'
' Faisal Khan
' fa****@stardeve loper.com
' www.stardeveloper.com
' Class for handling binary uploads

Class Loader
Private dict

Private Sub Class_Initializ e
Set dict = Server.CreateOb ject("Scripting .Dictionary")
End Sub

Private Sub Class_Terminate
If IsObject(intDic t) Then
intDict.RemoveA ll
Set intDict = Nothing
End If
If IsObject(dict) Then
dict.RemoveAll
Set dict = Nothing
End If
End Sub

Public Property Get Count
Count = dict.Count
End Property

Public Sub Initialize
If Request.TotalBy tes > 0 Then
Dim binData
binData = Request.BinaryR ead(Request.Tot alBytes)
getData binData
End If
End Sub

Public Function getFileData(nam e)
If dict.Exists(nam e) Then
getFileData = dict(name).Item ("Value")
Else
getFileData = ""
End If
End Function

Public Function getValue(name)
Dim gv
If dict.Exists(nam e) Then
gv = CStr(dict(name) .Item("Value"))

gv = Left(gv,Len(gv)-2)
getValue = gv
Else
getValue = ""
End If
End Function

Public Function saveToFile(name , path)
If dict.Exists(nam e) Then
Dim temp
temp = dict(name).Item ("Value")
Dim fso
Set fso = Server.CreateOb ject("Scripting .FileSystemObje ct")
Dim file
Set file = fso.CreateTextF ile(path)
For tPoint = 1 to LenB(temp)
file.Write Chr(AscB(MidB(t emp,tPoint,1)))
Next
file.Close
saveToFile = True
Else
saveToFile = False
End If
End Function

Public Function getFileName(nam e)
If dict.Exists(nam e) Then
Dim temp, tempPos
temp = dict(name).Item ("FileName")
tempPos = 1 + InStrRev(temp, "\")
getFileName = Mid(temp, tempPos)
Else
getFileName = ""
End If
End Function

Public Function getFilePath(nam e)
If dict.Exists(nam e) Then
Dim temp, tempPos
temp = dict(name).Item ("FileName")
tempPos = InStrRev(temp, "\")
getFilePath = Mid(temp, 1, tempPos)
Else
getFilePath = ""
End If
End Function

Public Function getFilePathComp lete(name)
If dict.Exists(nam e) Then
getFilePathComp lete = dict(name).Item ("FileName")
Else
getFilePathComp lete = ""
End If
End Function

Public Function getFileSize(nam e)
If dict.Exists(nam e) Then
getFileSize = LenB(dict(name) .Item("Value"))
Else
getFileSize = 0
End If
End Function

Public Function getFileSizeTran slated(name)
If dict.Exists(nam e) Then
temp = LenB(dict(name) .Item("Value"))
If temp <= 1024 Then
getFileSizeTran slated = temp & " bytes"
Else
temp = FormatNumber((t emp / 1024), 2)
getFileSizeTran slated = temp & " kilobytes"
End If
Else
getFileSizeTran slated = ""
End If
End Function

Public Function getContentType( name)
If dict.Exists(nam e) Then
getContentType = dict(name).Item ("ContentTyp e")
Else
getContentType = ""
End If
End Function

Private Sub getData(rawData )
Dim separator
separator = MidB(rawData, 1, InstrB(1, rawData, ChrB(13)) - 1)

Dim lenSeparator
lenSeparator = LenB(separator)

Dim currentPos
currentPos = 1
Dim inStrByte
inStrByte = 1
Dim value, mValue
Dim tempValue
tempValue = ""

While inStrByte > 0
inStrByte = InStrB(currentP os, rawData, separator)
mValue = inStrByte - currentPos

If mValue > 1 Then
value = MidB(rawData, currentPos, mValue)

Dim begPos, endPos, midValue, nValue
Dim intDict
Set intDict = Server.CreateOb ject("Scripting .Dictionary")

begPos = 1 + InStrB(1, value, ChrB(34))
endPos = InStrB(begPos + 1, value, ChrB(34))
nValue = endPos

Dim nameN
nameN = MidB(value, begPos, endPos - begPos)

Dim nameValue, isValid
isValid = True

If InStrB(1, value, stringToByte("C ontent-Type")) > 1 Then

begPos = 1 + InStrB(endPos + 1, value, ChrB(34))
endPos = InStrB(begPos + 1, value, ChrB(34))

If endPos = 0 Then
endPos = begPos + 1
isValid = False
End If

midValue = MidB(value, begPos, endPos - begPos)
intDict.Add "FileName", trim(byteToStri ng(midValue))

begPos = 14 + InStrB(endPos + 1, value,
stringToByte("C ontent-Type:"))
endPos = InStrB(begPos, value, ChrB(13))

midValue = MidB(value, begPos, endPos - begPos)
intDict.Add "ContentTyp e", trim(byteToStri ng(midValue))

begPos = endPos + 4
endPos = LenB(value)

nameValue = MidB(value, begPos, ((endPos - begPos) - 1))
Else
nameValue = trim(byteToStri ng(MidB(value, nValue + 5)))
End If

If isValid = True Then

intDict.Add "Value", nameValue
intDict.Add "Name", nameN

dict.Add byteToString(na meN), intDict
End If
End If

currentPos = lenSeparator + inStrByte
Wend
End Sub

End Class

Private Function stringToByte(to Conv)
Dim tempChar
For i = 1 to Len(toConv)
tempChar = Mid(toConv, i, 1)
stringToByte = stringToByte & chrB(AscB(tempC har))
Next
End Function

Private Function byteToString(to Conv)
For i = 1 to LenB(toConv)
byteToString = byteToString & Chr(AscB(MidB(t oConv,i,1)))
Next
End Function
%>
Jul 22 '05 #1
4 2232
I had to add the following:

<httpRuntime executionTimeou t="300" maxRequestLengt h="16384" />

to my web.config for the project to increase the allowed file size to
16M.

Ignus

"Scott Baxter" <sc***@baxtsoft .com> wrote in message
news:uW******** ******@TK2MSFTN GP09.phx.gbl...
Hello,

I got the following scripts to upload files to my directories

I call insert.htm

Browse for a file, then click 'submit'

It works for small files, and for a small .mdb (access file)

But for any larger file, it quits and give me 'page not found'

Is there some kind of timeout I can set?

Note: insert.htm calls insert.asp, call load.asp

Thanks:

Insert.asp:

<!-- insert.htm -->
<html>
<head>
<title>File Uploading with ASP</title>
<style>
body, input { font-family:verdana, arial; font-size:10pt; }
</style>
</head>
<body>
<p align="center">
<b>File Uploading with ASP</b><br>
<a href="show.asp" >To see uploaded data click here</a>
</p>

<table border="0" align="center">
<tr>
<form method="POST" enctype="multip art/form-data" action="Insert. asp">
<td>Name :</td><td>
<input type="text" name="name" size="40"></td></tr>
<td>File :</td><td>
<input type="file" name="file" size="40"></td></tr>
<td> </td><td>
<input type="submit" value="Submit"> </td></tr>
</form>
</tr>
</table>

</body>
</html>
insert.asp:

<% ' Insert.asp %>
<!--#include file="Loader.as p"-->
<%

Response.Buffer = True

' load object
Dim load
Set load = new Loader

' calling initialize method
load.initialize
response.write "<br>hi1122 "

' File binary data
Dim fileData
fileData = load.getFileDat a("file")
' File name
Dim fileName
fileName = LCase(load.getF ileName("file") )
' File path
Dim filePath
filePath = load.getFilePat h("file")
' File path complete
Dim filePathComplet e
filePathComplet e = load.getFilePat hComplete("file ")
' File size
Dim fileSize
fileSize = load.getFileSiz e("file")
' File size translated
Dim fileSizeTransla ted
fileSizeTransla ted = load.getFileSiz eTranslated("fi le")
' Content Type
Dim contentType
contentType = load.getContent Type("file")
' No. of Form elements
Dim countElements
countElements = load.Count
' Value of text input field "name"
Dim nameInput
nameInput = load.getValue(" name")
' Path where file will be uploaded
Dim pathToFile
' pathToFile = Server.mapPath( "uploaded/") & "\" & fileName
pathToFile = Server.mapPath( "businessse arch/") & "\" & fileName
' Uploading file data
response.write "<br>hi1122 33"
response.write "<br> " & pathtofile
'response.end
Dim fileUploaded
fileUploaded = load.saveToFile ("file", pathToFile)
'response.write "<br>hi11223344 4"
'response.end
' destroying load object
Set load = Nothing
%>

<html>
<head>
<title>File Uploading with ASP</title>
<style>
body, input, td { font-family:verdana, arial; font-size:10pt; }
</style>
</head>
<body>
<p align="center">
<b>File Uploading with ASP</b><br>
<a href="show.asp" >To see uploaded files click here</a>
</p>

<table width="700" border="1" align="center">
<tr>
<td>File Name</td><td><%= fileName %></td>
</tr><tr>
<td>File Path</td><td><%= filePath %></td>
</tr><tr>
<td>File Path Complete</td><td><%= filePathComplet e %></td>
</tr><tr>
<td>File Size</td><td><%= fileSize %></td>
</tr><tr>
<td>File Size Translated</td><td><%= fileSizeTransla ted %></td>
</tr><tr>
<td>Content Type</td><td><%= contentType %></td>
</tr><tr>
<td>No. of Form Elements</td><td><%= countElements %></td>
</tr><tr>
<td>Name</td><td><%= nameInput %></td>
</tr>
</table><br><br>

<p style="padding-left:220;">
<%
If fileUploaded = True Then
Response.Write fileName & " data uploaded..."
Else
Response.Write "<font color=""red"">F ile could not be uploaded..."
Response.Write "</font>"
Response.Write "<br>Please select a file before hitting the
'Submit'"
Response.Write " button."
End If
%>
</p>

<br>
<table border="0" align="center">
<tr>
<form method="POST" enctype="multip art/form-data" action="Insert. asp">
<td>Name :</td><td>
<input type="text" name="name" size="40" value="<%= nameInput %>">
</td></tr>
<td>File :</td><td>
<input type="file" name="file" size="40"></td></tr>
<td> </td><td>
<input type="submit" value="Submit"> </td></tr>
</form>
</tr>
</table>

</body>
</html>
loader.asp:

<%
' -- Loader.asp --
' -- version 1.5.2
' -- last updated 12/5/2002
'
' Faisal Khan
' fa****@stardeve loper.com
' www.stardeveloper.com
' Class for handling binary uploads

Class Loader
Private dict

Private Sub Class_Initializ e
Set dict = Server.CreateOb ject("Scripting .Dictionary")
End Sub

Private Sub Class_Terminate
If IsObject(intDic t) Then
intDict.RemoveA ll
Set intDict = Nothing
End If
If IsObject(dict) Then
dict.RemoveAll
Set dict = Nothing
End If
End Sub

Public Property Get Count
Count = dict.Count
End Property

Public Sub Initialize
If Request.TotalBy tes > 0 Then
Dim binData
binData = Request.BinaryR ead(Request.Tot alBytes)
getData binData
End If
End Sub

Public Function getFileData(nam e)
If dict.Exists(nam e) Then
getFileData = dict(name).Item ("Value")
Else
getFileData = ""
End If
End Function

Public Function getValue(name)
Dim gv
If dict.Exists(nam e) Then
gv = CStr(dict(name) .Item("Value"))

gv = Left(gv,Len(gv)-2)
getValue = gv
Else
getValue = ""
End If
End Function

Public Function saveToFile(name , path)
If dict.Exists(nam e) Then
Dim temp
temp = dict(name).Item ("Value")
Dim fso
Set fso = Server.CreateOb ject("Scripting .FileSystemObje ct")
Dim file
Set file = fso.CreateTextF ile(path)
For tPoint = 1 to LenB(temp)
file.Write Chr(AscB(MidB(t emp,tPoint,1)))
Next
file.Close
saveToFile = True
Else
saveToFile = False
End If
End Function

Public Function getFileName(nam e)
If dict.Exists(nam e) Then
Dim temp, tempPos
temp = dict(name).Item ("FileName")
tempPos = 1 + InStrRev(temp, "\")
getFileName = Mid(temp, tempPos)
Else
getFileName = ""
End If
End Function

Public Function getFilePath(nam e)
If dict.Exists(nam e) Then
Dim temp, tempPos
temp = dict(name).Item ("FileName")
tempPos = InStrRev(temp, "\")
getFilePath = Mid(temp, 1, tempPos)
Else
getFilePath = ""
End If
End Function

Public Function getFilePathComp lete(name)
If dict.Exists(nam e) Then
getFilePathComp lete = dict(name).Item ("FileName")
Else
getFilePathComp lete = ""
End If
End Function

Public Function getFileSize(nam e)
If dict.Exists(nam e) Then
getFileSize = LenB(dict(name) .Item("Value"))
Else
getFileSize = 0
End If
End Function

Public Function getFileSizeTran slated(name)
If dict.Exists(nam e) Then
temp = LenB(dict(name) .Item("Value"))
If temp <= 1024 Then
getFileSizeTran slated = temp & " bytes"
Else
temp = FormatNumber((t emp / 1024), 2)
getFileSizeTran slated = temp & " kilobytes"
End If
Else
getFileSizeTran slated = ""
End If
End Function

Public Function getContentType( name)
If dict.Exists(nam e) Then
getContentType = dict(name).Item ("ContentTyp e")
Else
getContentType = ""
End If
End Function

Private Sub getData(rawData )
Dim separator
separator = MidB(rawData, 1, InstrB(1, rawData, ChrB(13)) - 1)

Dim lenSeparator
lenSeparator = LenB(separator)

Dim currentPos
currentPos = 1
Dim inStrByte
inStrByte = 1
Dim value, mValue
Dim tempValue
tempValue = ""

While inStrByte > 0
inStrByte = InStrB(currentP os, rawData, separator)
mValue = inStrByte - currentPos

If mValue > 1 Then
value = MidB(rawData, currentPos, mValue)

Dim begPos, endPos, midValue, nValue
Dim intDict
Set intDict = Server.CreateOb ject("Scripting .Dictionary")

begPos = 1 + InStrB(1, value, ChrB(34))
endPos = InStrB(begPos + 1, value, ChrB(34))
nValue = endPos

Dim nameN
nameN = MidB(value, begPos, endPos - begPos)

Dim nameValue, isValid
isValid = True

If InStrB(1, value, stringToByte("C ontent-Type")) > 1 Then

begPos = 1 + InStrB(endPos + 1, value, ChrB(34))
endPos = InStrB(begPos + 1, value, ChrB(34))

If endPos = 0 Then
endPos = begPos + 1
isValid = False
End If

midValue = MidB(value, begPos, endPos - begPos)
intDict.Add "FileName", trim(byteToStri ng(midValue))

begPos = 14 + InStrB(endPos + 1, value,
stringToByte("C ontent-Type:"))
endPos = InStrB(begPos, value, ChrB(13))

midValue = MidB(value, begPos, endPos - begPos)
intDict.Add "ContentTyp e", trim(byteToStri ng(midValue))

begPos = endPos + 4
endPos = LenB(value)

nameValue = MidB(value, begPos, ((endPos - begPos) - 1))
Else
nameValue = trim(byteToStri ng(MidB(value, nValue + 5)))
End If

If isValid = True Then

intDict.Add "Value", nameValue
intDict.Add "Name", nameN

dict.Add byteToString(na meN), intDict
End If
End If

currentPos = lenSeparator + inStrByte
Wend
End Sub

End Class

Private Function stringToByte(to Conv)
Dim tempChar
For i = 1 to Len(toConv)
tempChar = Mid(toConv, i, 1)
stringToByte = stringToByte & chrB(AscB(tempC har))
Next
End Function

Private Function byteToString(to Conv)
For i = 1 to LenB(toConv)
byteToString = byteToString & Chr(AscB(MidB(t oConv,i,1)))
Next
End Function
%>

Jul 22 '05 #2
If the server OS is 2003, that OS has a 200 KB upload limit. It can be
increased by editting the metabase.xml file.

MIke

"Scott Baxter" wrote:
Hello,

I got the following scripts to upload files to my directories

I call insert.htm

Browse for a file, then click 'submit'

It works for small files, and for a small .mdb (access file)

But for any larger file, it quits and give me 'page not found'

Is there some kind of timeout I can set?

Note: insert.htm calls insert.asp, call load.asp

Thanks:

Insert.asp:

<!-- insert.htm -->
<html>
<head>
<title>File Uploading with ASP</title>
<style>
body, input { font-family:verdana, arial; font-size:10pt; }
</style>
</head>
<body>
<p align="center">
<b>File Uploading with ASP</b><br>
<a href="show.asp" >To see uploaded data click here</a>
</p>

<table border="0" align="center">
<tr>
<form method="POST" enctype="multip art/form-data" action="Insert. asp">
<td>Name :</td><td>
<input type="text" name="name" size="40"></td></tr>
<td>File :</td><td>
<input type="file" name="file" size="40"></td></tr>
<td> </td><td>
<input type="submit" value="Submit"> </td></tr>
</form>
</tr>
</table>

</body>
</html>
insert.asp:

<% ' Insert.asp %>
<!--#include file="Loader.as p"-->
<%

Response.Buffer = True

' load object
Dim load
Set load = new Loader

' calling initialize method
load.initialize
response.write "<br>hi1122 "

' File binary data
Dim fileData
fileData = load.getFileDat a("file")
' File name
Dim fileName
fileName = LCase(load.getF ileName("file") )
' File path
Dim filePath
filePath = load.getFilePat h("file")
' File path complete
Dim filePathComplet e
filePathComplet e = load.getFilePat hComplete("file ")
' File size
Dim fileSize
fileSize = load.getFileSiz e("file")
' File size translated
Dim fileSizeTransla ted
fileSizeTransla ted = load.getFileSiz eTranslated("fi le")
' Content Type
Dim contentType
contentType = load.getContent Type("file")
' No. of Form elements
Dim countElements
countElements = load.Count
' Value of text input field "name"
Dim nameInput
nameInput = load.getValue(" name")
' Path where file will be uploaded
Dim pathToFile
' pathToFile = Server.mapPath( "uploaded/") & "\" & fileName
pathToFile = Server.mapPath( "businessse arch/") & "\" & fileName
' Uploading file data
response.write "<br>hi1122 33"
response.write "<br> " & pathtofile
'response.end
Dim fileUploaded
fileUploaded = load.saveToFile ("file", pathToFile)
'response.write "<br>hi11223344 4"
'response.end
' destroying load object
Set load = Nothing
%>

<html>
<head>
<title>File Uploading with ASP</title>
<style>
body, input, td { font-family:verdana, arial; font-size:10pt; }
</style>
</head>
<body>
<p align="center">
<b>File Uploading with ASP</b><br>
<a href="show.asp" >To see uploaded files click here</a>
</p>

<table width="700" border="1" align="center">
<tr>
<td>File Name</td><td><%= fileName %></td>
</tr><tr>
<td>File Path</td><td><%= filePath %></td>
</tr><tr>
<td>File Path Complete</td><td><%= filePathComplet e %></td>
</tr><tr>
<td>File Size</td><td><%= fileSize %></td>
</tr><tr>
<td>File Size Translated</td><td><%= fileSizeTransla ted %></td>
</tr><tr>
<td>Content Type</td><td><%= contentType %></td>
</tr><tr>
<td>No. of Form Elements</td><td><%= countElements %></td>
</tr><tr>
<td>Name</td><td><%= nameInput %></td>
</tr>
</table><br><br>

<p style="padding-left:220;">
<%
If fileUploaded = True Then
Response.Write fileName & " data uploaded..."
Else
Response.Write "<font color=""red"">F ile could not be uploaded..."
Response.Write "</font>"
Response.Write "<br>Please select a file before hitting the
'Submit'"
Response.Write " button."
End If
%>
</p>

<br>
<table border="0" align="center">
<tr>
<form method="POST" enctype="multip art/form-data" action="Insert. asp">
<td>Name :</td><td>
<input type="text" name="name" size="40" value="<%= nameInput %>">
</td></tr>
<td>File :</td><td>
<input type="file" name="file" size="40"></td></tr>
<td> </td><td>
<input type="submit" value="Submit"> </td></tr>
</form>
</tr>
</table>

</body>
</html>
loader.asp:

<%
' -- Loader.asp --
' -- version 1.5.2
' -- last updated 12/5/2002
'
' Faisal Khan
' fa****@stardeve loper.com
' www.stardeveloper.com
' Class for handling binary uploads

Class Loader
Private dict

Private Sub Class_Initializ e
Set dict = Server.CreateOb ject("Scripting .Dictionary")
End Sub

Private Sub Class_Terminate
If IsObject(intDic t) Then
intDict.RemoveA ll
Set intDict = Nothing
End If
If IsObject(dict) Then
dict.RemoveAll
Set dict = Nothing
End If
End Sub

Public Property Get Count
Count = dict.Count
End Property

Public Sub Initialize
If Request.TotalBy tes > 0 Then
Dim binData
binData = Request.BinaryR ead(Request.Tot alBytes)
getData binData
End If
End Sub

Public Function getFileData(nam e)
If dict.Exists(nam e) Then
getFileData = dict(name).Item ("Value")
Else
getFileData = ""
End If
End Function

Public Function getValue(name)
Dim gv
If dict.Exists(nam e) Then
gv = CStr(dict(name) .Item("Value"))

gv = Left(gv,Len(gv)-2)
getValue = gv
Else
getValue = ""
End If
End Function

Public Function saveToFile(name , path)
If dict.Exists(nam e) Then
Dim temp
temp = dict(name).Item ("Value")
Dim fso
Set fso = Server.CreateOb ject("Scripting .FileSystemObje ct")
Dim file
Set file = fso.CreateTextF ile(path)
For tPoint = 1 to LenB(temp)
file.Write Chr(AscB(MidB(t emp,tPoint,1)))
Next
file.Close
saveToFile = True
Else
saveToFile = False
End If
End Function

Public Function getFileName(nam e)
If dict.Exists(nam e) Then
Dim temp, tempPos
temp = dict(name).Item ("FileName")
tempPos = 1 + InStrRev(temp, "\")
getFileName = Mid(temp, tempPos)
Else
getFileName = ""
End If
End Function

Public Function getFilePath(nam e)
If dict.Exists(nam e) Then
Dim temp, tempPos
temp = dict(name).Item ("FileName")
tempPos = InStrRev(temp, "\")
getFilePath = Mid(temp, 1, tempPos)
Else
getFilePath = ""
End If
End Function

Public Function getFilePathComp lete(name)
If dict.Exists(nam e) Then
getFilePathComp lete = dict(name).Item ("FileName")
Else
getFilePathComp lete = ""
End If
End Function

Public Function getFileSize(nam e)
If dict.Exists(nam e) Then
getFileSize = LenB(dict(name) .Item("Value"))
Else
getFileSize = 0
End If
End Function

Public Function getFileSizeTran slated(name)
If dict.Exists(nam e) Then
temp = LenB(dict(name) .Item("Value"))
If temp <= 1024 Then
getFileSizeTran slated = temp & " bytes"
Else
temp = FormatNumber((t emp / 1024), 2)
getFileSizeTran slated = temp & " kilobytes"
End If
Else
getFileSizeTran slated = ""
End If
End Function

Public Function getContentType( name)
If dict.Exists(nam e) Then
getContentType = dict(name).Item ("ContentTyp e")
Else
getContentType = ""
End If
End Function

Private Sub getData(rawData )
Dim separator
separator = MidB(rawData, 1, InstrB(1, rawData, ChrB(13)) - 1)

Dim lenSeparator
lenSeparator = LenB(separator)

Dim currentPos
currentPos = 1
Dim inStrByte
inStrByte = 1
Dim value, mValue
Dim tempValue
tempValue = ""

While inStrByte > 0
inStrByte = InStrB(currentP os, rawData, separator)
mValue = inStrByte - currentPos

If mValue > 1 Then
value = MidB(rawData, currentPos, mValue)

Dim begPos, endPos, midValue, nValue
Dim intDict
Set intDict = Server.CreateOb ject("Scripting .Dictionary")

begPos = 1 + InStrB(1, value, ChrB(34))
endPos = InStrB(begPos + 1, value, ChrB(34))
nValue = endPos

Dim nameN
nameN = MidB(value, begPos, endPos - begPos)

Dim nameValue, isValid
isValid = True

If InStrB(1, value, stringToByte("C ontent-Type")) > 1 Then

begPos = 1 + InStrB(endPos + 1, value, ChrB(34))
endPos = InStrB(begPos + 1, value, ChrB(34))

If endPos = 0 Then
endPos = begPos + 1
isValid = False
End If

midValue = MidB(value, begPos, endPos - begPos)
intDict.Add "FileName", trim(byteToStri ng(midValue))

begPos = 14 + InStrB(endPos + 1, value,
stringToByte("C ontent-Type:"))
endPos = InStrB(begPos, value, ChrB(13))

midValue = MidB(value, begPos, endPos - begPos)
intDict.Add "ContentTyp e", trim(byteToStri ng(midValue))

begPos = endPos + 4
endPos = LenB(value)

nameValue = MidB(value, begPos, ((endPos - begPos) - 1))
Else
nameValue = trim(byteToStri ng(MidB(value, nValue + 5)))
End If

If isValid = True Then

intDict.Add "Value", nameValue
intDict.Add "Name", nameN

dict.Add byteToString(na meN), intDict
End If
End If

currentPos = lenSeparator + inStrByte
Wend
End Sub

End Class

Private Function stringToByte(to Conv)
Dim tempChar
For i = 1 to Len(toConv)
tempChar = Mid(toConv, i, 1)
stringToByte = stringToByte & chrB(AscB(tempC har))
Next
End Function

Private Function byteToString(to Conv)
For i = 1 to LenB(toConv)
byteToString = byteToString & Chr(AscB(MidB(t oConv,i,1)))
Next
End Function
%>

Jul 22 '05 #3
Thanks Mike. Where is this file? I tried putting a web.config file, and it
didn't do anything. I put it in the directory where the insert.asp file is,
and the target directory where I wrote it. Here is the web.config I put
there:

<?xml version="1.0" encoding="utf-8" ?>
<configuratio n>
<system.web>
<httpRuntime
executionTimeou t="300"
maxRequestLengt h="16384"
/>
</system.web>
</configuration>

Do I need to do a command to get my web site to recognize this? It seemed
to have no effect.

Thanks.

Scott


"Mike D" <Mi***@discussi ons.microsoft.c om> wrote in message
news:11******** *************** ***********@mic rosoft.com...
If the server OS is 2003, that OS has a 200 KB upload limit. It can be
increased by editting the metabase.xml file.

MIke

"Scott Baxter" wrote:
Hello,

I got the following scripts to upload files to my directories

I call insert.htm

Browse for a file, then click 'submit'

It works for small files, and for a small .mdb (access file)

But for any larger file, it quits and give me 'page not found'

Is there some kind of timeout I can set?

Note: insert.htm calls insert.asp, call load.asp

Thanks:

Insert.asp:

<!-- insert.htm -->
<html>
<head>
<title>File Uploading with ASP</title>
<style>
body, input { font-family:verdana, arial; font-size:10pt; }
</style>
</head>
<body>
<p align="center">
<b>File Uploading with ASP</b><br>
<a href="show.asp" >To see uploaded data click here</a>
</p>

<table border="0" align="center">
<tr>
<form method="POST" enctype="multip art/form-data" action="Insert. asp">
<td>Name :</td><td>
<input type="text" name="name" size="40"></td></tr>
<td>File :</td><td>
<input type="file" name="file" size="40"></td></tr>
<td> </td><td>
<input type="submit" value="Submit"> </td></tr>
</form>
</tr>
</table>

</body>
</html>
insert.asp:

<% ' Insert.asp %>
<!--#include file="Loader.as p"-->
<%

Response.Buffer = True

' load object
Dim load
Set load = new Loader

' calling initialize method
load.initialize
response.write "<br>hi1122 "

' File binary data
Dim fileData
fileData = load.getFileDat a("file")
' File name
Dim fileName
fileName = LCase(load.getF ileName("file") )
' File path
Dim filePath
filePath = load.getFilePat h("file")
' File path complete
Dim filePathComplet e
filePathComplet e = load.getFilePat hComplete("file ")
' File size
Dim fileSize
fileSize = load.getFileSiz e("file")
' File size translated
Dim fileSizeTransla ted
fileSizeTransla ted = load.getFileSiz eTranslated("fi le")
' Content Type
Dim contentType
contentType = load.getContent Type("file")
' No. of Form elements
Dim countElements
countElements = load.Count
' Value of text input field "name"
Dim nameInput
nameInput = load.getValue(" name")
' Path where file will be uploaded
Dim pathToFile
' pathToFile = Server.mapPath( "uploaded/") & "\" & fileName
pathToFile = Server.mapPath( "businessse arch/") & "\" & fileName
' Uploading file data
response.write "<br>hi1122 33"
response.write "<br> " & pathtofile
'response.end
Dim fileUploaded
fileUploaded = load.saveToFile ("file", pathToFile)
'response.write "<br>hi11223344 4"
'response.end
' destroying load object
Set load = Nothing
%>

<html>
<head>
<title>File Uploading with ASP</title>
<style>
body, input, td { font-family:verdana, arial; font-size:10pt; }
</style>
</head>
<body>
<p align="center">
<b>File Uploading with ASP</b><br>
<a href="show.asp" >To see uploaded files click here</a>
</p>

<table width="700" border="1" align="center">
<tr>
<td>File Name</td><td><%= fileName %></td>
</tr><tr>
<td>File Path</td><td><%= filePath %></td>
</tr><tr>
<td>File Path Complete</td><td><%= filePathComplet e %></td>
</tr><tr>
<td>File Size</td><td><%= fileSize %></td>
</tr><tr>
<td>File Size Translated</td><td><%= fileSizeTransla ted %></td>
</tr><tr>
<td>Content Type</td><td><%= contentType %></td>
</tr><tr>
<td>No. of Form Elements</td><td><%= countElements %></td>
</tr><tr>
<td>Name</td><td><%= nameInput %></td>
</tr>
</table><br><br>

<p style="padding-left:220;">
<%
If fileUploaded = True Then
Response.Write fileName & " data uploaded..."
Else
Response.Write "<font color=""red"">F ile could not be uploaded..." Response.Write "</font>"
Response.Write "<br>Please select a file before hitting the
'Submit'"
Response.Write " button."
End If
%>
</p>

<br>
<table border="0" align="center">
<tr>
<form method="POST" enctype="multip art/form-data" action="Insert. asp"> <td>Name :</td><td>
<input type="text" name="name" size="40" value="<%= nameInput %>">
</td></tr>
<td>File :</td><td>
<input type="file" name="file" size="40"></td></tr>
<td> </td><td>
<input type="submit" value="Submit"> </td></tr>
</form>
</tr>
</table>

</body>
</html>
loader.asp:

<%
' -- Loader.asp --
' -- version 1.5.2
' -- last updated 12/5/2002
'
' Faisal Khan
' fa****@stardeve loper.com
' www.stardeveloper.com
' Class for handling binary uploads

Class Loader
Private dict

Private Sub Class_Initializ e
Set dict = Server.CreateOb ject("Scripting .Dictionary")
End Sub

Private Sub Class_Terminate
If IsObject(intDic t) Then
intDict.RemoveA ll
Set intDict = Nothing
End If
If IsObject(dict) Then
dict.RemoveAll
Set dict = Nothing
End If
End Sub

Public Property Get Count
Count = dict.Count
End Property

Public Sub Initialize
If Request.TotalBy tes > 0 Then
Dim binData
binData = Request.BinaryR ead(Request.Tot alBytes)
getData binData
End If
End Sub

Public Function getFileData(nam e)
If dict.Exists(nam e) Then
getFileData = dict(name).Item ("Value")
Else
getFileData = ""
End If
End Function

Public Function getValue(name)
Dim gv
If dict.Exists(nam e) Then
gv = CStr(dict(name) .Item("Value"))

gv = Left(gv,Len(gv)-2)
getValue = gv
Else
getValue = ""
End If
End Function

Public Function saveToFile(name , path)
If dict.Exists(nam e) Then
Dim temp
temp = dict(name).Item ("Value")
Dim fso
Set fso = Server.CreateOb ject("Scripting .FileSystemObje ct")
Dim file
Set file = fso.CreateTextF ile(path)
For tPoint = 1 to LenB(temp)
file.Write Chr(AscB(MidB(t emp,tPoint,1)))
Next
file.Close
saveToFile = True
Else
saveToFile = False
End If
End Function

Public Function getFileName(nam e)
If dict.Exists(nam e) Then
Dim temp, tempPos
temp = dict(name).Item ("FileName")
tempPos = 1 + InStrRev(temp, "\")
getFileName = Mid(temp, tempPos)
Else
getFileName = ""
End If
End Function

Public Function getFilePath(nam e)
If dict.Exists(nam e) Then
Dim temp, tempPos
temp = dict(name).Item ("FileName")
tempPos = InStrRev(temp, "\")
getFilePath = Mid(temp, 1, tempPos)
Else
getFilePath = ""
End If
End Function

Public Function getFilePathComp lete(name)
If dict.Exists(nam e) Then
getFilePathComp lete = dict(name).Item ("FileName")
Else
getFilePathComp lete = ""
End If
End Function

Public Function getFileSize(nam e)
If dict.Exists(nam e) Then
getFileSize = LenB(dict(name) .Item("Value"))
Else
getFileSize = 0
End If
End Function

Public Function getFileSizeTran slated(name)
If dict.Exists(nam e) Then
temp = LenB(dict(name) .Item("Value"))
If temp <= 1024 Then
getFileSizeTran slated = temp & " bytes"
Else
temp = FormatNumber((t emp / 1024), 2)
getFileSizeTran slated = temp & " kilobytes"
End If
Else
getFileSizeTran slated = ""
End If
End Function

Public Function getContentType( name)
If dict.Exists(nam e) Then
getContentType = dict(name).Item ("ContentTyp e")
Else
getContentType = ""
End If
End Function

Private Sub getData(rawData )
Dim separator
separator = MidB(rawData, 1, InstrB(1, rawData, ChrB(13)) - 1)

Dim lenSeparator
lenSeparator = LenB(separator)

Dim currentPos
currentPos = 1
Dim inStrByte
inStrByte = 1
Dim value, mValue
Dim tempValue
tempValue = ""

While inStrByte > 0
inStrByte = InStrB(currentP os, rawData, separator)
mValue = inStrByte - currentPos

If mValue > 1 Then
value = MidB(rawData, currentPos, mValue)

Dim begPos, endPos, midValue, nValue
Dim intDict
Set intDict = Server.CreateOb ject("Scripting .Dictionary")

begPos = 1 + InStrB(1, value, ChrB(34))
endPos = InStrB(begPos + 1, value, ChrB(34))
nValue = endPos

Dim nameN
nameN = MidB(value, begPos, endPos - begPos)

Dim nameValue, isValid
isValid = True

If InStrB(1, value, stringToByte("C ontent-Type")) > 1 Then

begPos = 1 + InStrB(endPos + 1, value, ChrB(34))
endPos = InStrB(begPos + 1, value, ChrB(34))

If endPos = 0 Then
endPos = begPos + 1
isValid = False
End If

midValue = MidB(value, begPos, endPos - begPos)
intDict.Add "FileName", trim(byteToStri ng(midValue))

begPos = 14 + InStrB(endPos + 1, value,
stringToByte("C ontent-Type:"))
endPos = InStrB(begPos, value, ChrB(13))

midValue = MidB(value, begPos, endPos - begPos)
intDict.Add "ContentTyp e", trim(byteToStri ng(midValue))

begPos = endPos + 4
endPos = LenB(value)

nameValue = MidB(value, begPos, ((endPos - begPos) - 1))
Else
nameValue = trim(byteToStri ng(MidB(value, nValue + 5)))
End If

If isValid = True Then

intDict.Add "Value", nameValue
intDict.Add "Name", nameN

dict.Add byteToString(na meN), intDict
End If
End If

currentPos = lenSeparator + inStrByte
Wend
End Sub

End Class

Private Function stringToByte(to Conv)
Dim tempChar
For i = 1 to Len(toConv)
tempChar = Mid(toConv, i, 1)
stringToByte = stringToByte & chrB(AscB(tempC har))
Next
End Function

Private Function byteToString(to Conv)
For i = 1 to LenB(toConv)
byteToString = byteToString & Chr(AscB(MidB(t oConv,i,1)))
Next
End Function
%>

Jul 22 '05 #4
Actually, this setting (maxRequestLeng th) is done in the machine.config
file. Search your hard drive - mine is located in
C:\WINNT\Micros oft.NET\Framewo rk\v1.1.4322\CO NFIG

Bob Barrows
PS. In the future, could you leave microsoft.publi c.inetserver.as p.general
out of your crossposts for dotnet issues? That newsgroup is focussed on
classic ASP questions.

microsoft.publi c.scripting.vbs cript is not really relevant either.
Scott Baxter wrote:
Thanks Mike. Where is this file? I tried putting a web.config file,
and it didn't do anything. I put it in the directory where the
insert.asp file is, and the target directory where I wrote it. Here
is the web.config I put there:

<?xml version="1.0" encoding="utf-8" ?>
<configuratio n>
<system.web>
<httpRuntime
executionTimeou t="300"
maxRequestLengt h="16384"
/>
</system.web>
</configuration>

Do I need to do a command to get my web site to recognize this? It
seemed to have no effect.

Thanks.

Scott


"Mike D" <Mi***@discussi ons.microsoft.c om> wrote in message
news:11******** *************** ***********@mic rosoft.com...
If the server OS is 2003, that OS has a 200 KB upload limit. It can
be increased by editting the metabase.xml file.

MIke

"Scott Baxter" wrote:
Hello,

I got the following scripts to upload files to my directories

I call insert.htm

Browse for a file, then click 'submit'

It works for small files, and for a small .mdb (access file)

But for any larger file, it quits and give me 'page not found'

Is there some kind of timeout I can set?

Note: insert.htm calls insert.asp, call load.asp

Thanks:

Insert.asp:

<!-- insert.htm -->
<html>
<head>
<title>File Uploading with ASP</title>
<style>
body, input { font-family:verdana, arial; font-size:10pt; }
</style>
</head>
<body>
<p align="center">
<b>File Uploading with ASP</b><br>
<a href="show.asp" >To see uploaded data click here</a>
</p>

<table border="0" align="center">
<tr>
<form method="POST" enctype="multip art/form-data"
action="Insert. asp"> <td>Name :</td><td>
<input type="text" name="name" size="40"></td></tr>
<td>File :</td><td>
<input type="file" name="file" size="40"></td></tr>
<td> </td><td>
<input type="submit" value="Submit"> </td></tr>
</form>
</tr>
</table>

</body>
</html>
insert.asp:

<% ' Insert.asp %>
<!--#include file="Loader.as p"-->
<%

Response.Buffer = True

' load object
Dim load
Set load = new Loader

' calling initialize method
load.initialize
response.write "<br>hi1122 "

' File binary data
Dim fileData
fileData = load.getFileDat a("file")
' File name
Dim fileName
fileName = LCase(load.getF ileName("file") )
' File path
Dim filePath
filePath = load.getFilePat h("file")
' File path complete
Dim filePathComplet e
filePathComplet e = load.getFilePat hComplete("file ")
' File size
Dim fileSize
fileSize = load.getFileSiz e("file")
' File size translated
Dim fileSizeTransla ted
fileSizeTransla ted = load.getFileSiz eTranslated("fi le")
' Content Type
Dim contentType
contentType = load.getContent Type("file")
' No. of Form elements
Dim countElements
countElements = load.Count
' Value of text input field "name"
Dim nameInput
nameInput = load.getValue(" name")
' Path where file will be uploaded
Dim pathToFile
' pathToFile = Server.mapPath( "uploaded/") & "\" & fileName
pathToFile = Server.mapPath( "businessse arch/") & "\" & fileName
' Uploading file data
response.write "<br>hi1122 33"
response.write "<br> " & pathtofile
'response.end
Dim fileUploaded
fileUploaded = load.saveToFile ("file", pathToFile)
'response.write "<br>hi11223344 4"
'response.end
' destroying load object
Set load = Nothing
%>

<html>
<head>
<title>File Uploading with ASP</title>
<style>
body, input, td { font-family:verdana, arial; font-size:10pt; }
</style>
</head>
<body>
<p align="center">
<b>File Uploading with ASP</b><br>
<a href="show.asp" >To see uploaded files click here</a>
</p>

<table width="700" border="1" align="center">
<tr>
<td>File Name</td><td><%= fileName %></td>
</tr><tr>
<td>File Path</td><td><%= filePath %></td>
</tr><tr>
<td>File Path Complete</td><td><%= filePathComplet e %></td>
</tr><tr>
<td>File Size</td><td><%= fileSize %></td>
</tr><tr>
<td>File Size Translated</td><td><%= fileSizeTransla ted
%></td> </tr><tr>
<td>Content Type</td><td><%= contentType %></td>
</tr><tr>
<td>No. of Form Elements</td><td><%= countElements %></td>
</tr><tr>
<td>Name</td><td><%= nameInput %></td>
</tr>
</table><br><br>

<p style="padding-left:220;">
<%
If fileUploaded = True Then
Response.Write fileName & " data uploaded..."
Else
Response.Write "<font color=""red"">F ile could not be
uploaded..." Response.Write "</font>"
Response.Write "<br>Please select a file before hitting the
'Submit'"
Response.Write " button."
End If
%>
</p>

<br>
<table border="0" align="center">
<tr>
<form method="POST" enctype="multip art/form-data"
action="Insert. asp"> <td>Name :</td><td>
<input type="text" name="name" size="40" value="<%= nameInput
%>"> </td></tr>
<td>File :</td><td>
<input type="file" name="file" size="40"></td></tr>
<td> </td><td>
<input type="submit" value="Submit"> </td></tr>
</form>
</tr>
</table>

</body>
</html>
loader.asp:

<%
' -- Loader.asp --
' -- version 1.5.2
' -- last updated 12/5/2002
'
' Faisal Khan
' fa****@stardeve loper.com
' www.stardeveloper.com
' Class for handling binary uploads

Class Loader
Private dict

Private Sub Class_Initializ e
Set dict = Server.CreateOb ject("Scripting .Dictionary")
End Sub

Private Sub Class_Terminate
If IsObject(intDic t) Then
intDict.RemoveA ll
Set intDict = Nothing
End If
If IsObject(dict) Then
dict.RemoveAll
Set dict = Nothing
End If
End Sub

Public Property Get Count
Count = dict.Count
End Property

Public Sub Initialize
If Request.TotalBy tes > 0 Then
Dim binData
binData = Request.BinaryR ead(Request.Tot alBytes)
getData binData
End If
End Sub

Public Function getFileData(nam e)
If dict.Exists(nam e) Then
getFileData = dict(name).Item ("Value")
Else
getFileData = ""
End If
End Function

Public Function getValue(name)
Dim gv
If dict.Exists(nam e) Then
gv = CStr(dict(name) .Item("Value"))

gv = Left(gv,Len(gv)-2)
getValue = gv
Else
getValue = ""
End If
End Function

Public Function saveToFile(name , path)
If dict.Exists(nam e) Then
Dim temp
temp = dict(name).Item ("Value")
Dim fso
Set fso =
Server.CreateOb ject("Scripting .FileSystemObje ct") Dim file
Set file = fso.CreateTextF ile(path)
For tPoint = 1 to LenB(temp)
file.Write Chr(AscB(MidB(t emp,tPoint,1)))
Next
file.Close
saveToFile = True
Else
saveToFile = False
End If
End Function

Public Function getFileName(nam e)
If dict.Exists(nam e) Then
Dim temp, tempPos
temp = dict(name).Item ("FileName")
tempPos = 1 + InStrRev(temp, "\")
getFileName = Mid(temp, tempPos)
Else
getFileName = ""
End If
End Function

Public Function getFilePath(nam e)
If dict.Exists(nam e) Then
Dim temp, tempPos
temp = dict(name).Item ("FileName")
tempPos = InStrRev(temp, "\")
getFilePath = Mid(temp, 1, tempPos)
Else
getFilePath = ""
End If
End Function

Public Function getFilePathComp lete(name)
If dict.Exists(nam e) Then
getFilePathComp lete = dict(name).Item ("FileName")
Else
getFilePathComp lete = ""
End If
End Function

Public Function getFileSize(nam e)
If dict.Exists(nam e) Then
getFileSize = LenB(dict(name) .Item("Value"))
Else
getFileSize = 0
End If
End Function

Public Function getFileSizeTran slated(name)
If dict.Exists(nam e) Then
temp = LenB(dict(name) .Item("Value"))
If temp <= 1024 Then
getFileSizeTran slated = temp & " bytes"
Else
temp = FormatNumber((t emp / 1024), 2)
getFileSizeTran slated = temp & " kilobytes"
End If
Else
getFileSizeTran slated = ""
End If
End Function

Public Function getContentType( name)
If dict.Exists(nam e) Then
getContentType = dict(name).Item ("ContentTyp e")
Else
getContentType = ""
End If
End Function

Private Sub getData(rawData )
Dim separator
separator = MidB(rawData, 1, InstrB(1, rawData, ChrB(13)) - 1)

Dim lenSeparator
lenSeparator = LenB(separator)

Dim currentPos
currentPos = 1
Dim inStrByte
inStrByte = 1
Dim value, mValue
Dim tempValue
tempValue = ""

While inStrByte > 0
inStrByte = InStrB(currentP os, rawData, separator)
mValue = inStrByte - currentPos

If mValue > 1 Then
value = MidB(rawData, currentPos, mValue)

Dim begPos, endPos, midValue, nValue
Dim intDict
Set intDict = Server.CreateOb ject("Scripting .Dictionary")

begPos = 1 + InStrB(1, value, ChrB(34))
endPos = InStrB(begPos + 1, value, ChrB(34))
nValue = endPos

Dim nameN
nameN = MidB(value, begPos, endPos - begPos)

Dim nameValue, isValid
isValid = True

If InStrB(1, value, stringToByte("C ontent-Type")) > 1 Then

begPos = 1 + InStrB(endPos + 1, value, ChrB(34))
endPos = InStrB(begPos + 1, value, ChrB(34))

If endPos = 0 Then
endPos = begPos + 1
isValid = False
End If

midValue = MidB(value, begPos, endPos - begPos)
intDict.Add "FileName", trim(byteToStri ng(midValue))

begPos = 14 + InStrB(endPos + 1, value,
stringToByte("C ontent-Type:"))
endPos = InStrB(begPos, value, ChrB(13))

midValue = MidB(value, begPos, endPos - begPos)
intDict.Add "ContentTyp e",
trim(byteToStri ng(midValue))

begPos = endPos + 4
endPos = LenB(value)

nameValue = MidB(value, begPos, ((endPos - begPos) - 1))
Else
nameValue = trim(byteToStri ng(MidB(value, nValue + 5)))
End If

If isValid = True Then

intDict.Add "Value", nameValue
intDict.Add "Name", nameN

dict.Add byteToString(na meN), intDict
End If
End If

currentPos = lenSeparator + inStrByte
Wend
End Sub

End Class

Private Function stringToByte(to Conv)
Dim tempChar
For i = 1 to Len(toConv)
tempChar = Mid(toConv, i, 1)
stringToByte = stringToByte & chrB(AscB(tempC har))
Next
End Function

Private Function byteToString(to Conv)
For i = 1 to LenB(toConv)
byteToString = byteToString & Chr(AscB(MidB(t oConv,i,1)))
Next
End Function
%>


--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 22 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1983
by: jrefactors | last post by:
I posted this question before but no replied. I really need some suggestions. The JSP application is deployed in IBM Websphere, and it has file upload operation. The problem is if the user upload a huge file like 20 MB, it will returns "Page cannot be displayed" in the browser after 30 seconds. If upload a small file size, it doesn't have any problems. I tested it in local machine with WSAD, and it can upload any file size. I suspect it...
6
4329
by: Russell Stevens | last post by:
I use a WinForm app for users to upload a file to my server. Basically one line of code; Response = WC.UploadData(MyUrl, "PUT", MyByteArray) Works fine except for larger files. After about 104 seconds I get a System.Net.WebException in System.dll. The message is "The operation has timed out". On my server, I have modified the machine.config file for the httpRuntime
4
9457
by: UJ | last post by:
I have a page where the user can upload a video file. As you can guess, this may take a while. Is there a way I can change the session timeout for just this one page? I would also want to change the forms authentication to be a large value for that page also. TIA - Jeff.
9
20901
by: 8anos | last post by:
Hello, I am new at the community and newbie at programming :) As you may know rapidshare provides a perl script for linux, to upload files at their servers. You can find the original scripts at rapidshare news : http://images.rapidshare.com/software/rsapi.pl If you test it you will see that you can upload one file at time. I try to modify it in that way that script can read a text file with the names of the files i want to...
8
3521
by: michal | last post by:
hi guys, i was wondering how you deal with script timeouts caused by huge file uploads. Lets say I have a script timeout of 2 minutes and the user uploads a file which takes more than this ... Whats the best way to inform the user about this issue rather than throwing the script timeout error. What approaches do you use for this....
1
1674
by: Mufasa | last post by:
Is there a way to set the timeouts for inactivity to be specific for a specific page? My memory is the answer is no. I have a script that is on every page at the moment that after twenty minutes of inactivity automatically logs you out. I can turn that off for the specific page but I assume I'll lose my session variables and what not at the timeout.
5
3289
by: camphor | last post by:
hi, I have found an upload script in hotscripts and have implemented it into the website, I followed the installation steps to 'give write permissions to php on the upload folder (which is _uploadedfiles_xxxx) (php must be allowed to move uploaded files to this folder' - uploadedfiles_xxxx. I typed <?php chmod ('_uploadedfiles_xxxx',640); ?> into notepad and saved it as php in the uploaded_xxxx folder, when I went to test it, the error...
2
4384
by: Piotrekk | last post by:
Hi I am trying to upload a 700 mb file using webrequest/response model. At 3x% I am getting the same error: "Unable to write data to the transport connection: an established connection was aborted by the software in your host machine" CLIENT side script is:
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10330
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10093
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9952
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8976
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4053
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3654
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.