Solved

Posted on 2006-05-01
397 Views

<%

call RequestBin()

function RequestBin()

PosBegin = 1
PosEnd = InStrB(1,RequestBin,getByte(chr(13)))

If PosEnd > 0 then
boundary = MidB(RequestBin,PosBegin,PosEnd-PosBegin)
boundaryPos = MidB(PosBegin,RequestBin,boundary)
End If

If boundary <> 0 then

PosEnd = InStrB(PosBegin,RequestBin,getByte(chr("&")))

Do While PosBegin < LenB(RequestBin)
Temp = getString(MidB(RequestBin,PosBegin,PosEnd-PosBegin))
tempPos = InStr(PosBegin,Temp,"=")
Name = URLDecode(Left(Temp,tempPos-PosBegin))
Value = URLDecode(Right(Temp,Len(Temp)-tempPos))
PosBegin = PosEnd + 1
PosEnd = InStrB(PosBegin,RequestBin,getByte(chr("&")))
If PosEnd = 0 then PosEnd = LenB(RequestBin) + 1
Loop
Else
Do Until(boundaryPos=InStrB(RequestBin,boundary & getByte("--")))
Pos = InStrB(boundaryPos,RequestBin,getByte("Content-Disposition"))
Pos = InStrB(Pos,RequestBin,getByte("name="))
PosBegin = Pos + 6
PosEnd = InStrB(PosBegin,RequestBin,getByte(chr(34)))
Name = getString(MidB(RequestBin,PosBegin,PosEnd-PosBegin))
Pos = InStrB(boundaryPos,RequestBin,getByte("filename="))
boundaryPos = MidB(PosBegin,RequestBin,boundary)
If Pos <> 0 AND (Pos<boundaryPos) Then
PosBegin = Pos + 10
PosEnd = InStrB(PosBegin,RequestBin,getByte(chr(34)))
FileName = getString(MidB(RequestBin,PosBegin,PosEnd-PosBegin))
Pos = InStrB(boundaryPos,RequestBin,getByte("Content-Type:"))
PosBegin = Pos + 14
PosEnd = InStrB(PosBegin,RequestBin,getByte(chr(13)))
ContentType = getString(MidB(RequestBin,PosBegin,PosEnd-PosBegin))
PosBegin = Pos + 4
PosEnd = InStrB(PosBegin,RequestBin,boundaryPos) - 2
Value = getString(MidB(RequestBin,PosBegin,PosEnd-PosBegin))
Else
boundaryPos=InstrB(boundaryPos+LenB(boundary),RequestBin,boundary)
End If
Loop
End if

Set ScriptObject = Server.CreateObject("Scripting.FileSystemObject")
Set MyFile = ScriptObject.CreateTextFile(Server.mappath("db/" & FileName))

End function

function URLDecode(sText)

sDecoded = sText
Set oRegExpr = Server.CreateObject("VBScript.RegExp")
oRegExpr.Pattern = "%[0-9,A-F]{2}"
oRegExpr.Global = True
Set oMatchCollection = oRegExpr.Execute(sText)
For Each oMatch In oMatchCollection
sDecoded = Replace(sDecoded,oMatch.value,Chr(CInt("&H" & Right(oMatch.Value,2))))
Next
URLDecode = sDecoded

End function

Function getString(StringBin)

getString =""
For intCount = 1 to LenB(StringBin)
getString = getString & chr(AscB(MidB(StringBin,intCount,1)))
Next

End Function

Function getByte(ByteBin)

getByte =""
For intCount = 1 to Len(ByteBin)
getByte = getByte & chrB(AscB(MidB(ByteBin,intCount,1)))
Next

End Function

%>

<HTML>
<BODY>
<input TYPE="file" NAME="blob" class="input" size="20">
</form>
</body>
</html>

0
Question by:eugene007

LVL 7

Expert Comment

I've used PureASP from

http://www.pstruh.cz/help/ScptUtl/library.htm

It is free, does not need components, comes with a working example, and even a novice like myself can edit it to work the way I want it to.
0

LVL 25

Expert Comment

you actually aren't doing anything other than calling RequestBin().  It looks like you need to pass variables to it in order for it to do the processing.

Do you have a link to where you got this script from?
0

Author Comment

0

LVL 25

Expert Comment

ok.  Like I said, you aren't doing any processing on your fileupload.asp page

see the first link you posted:
<%

If Request.TotalBytes > 0 Then

For lngLoop = 0 to objUpload.Files.Count - 1
'the internet guest account must have
'write permission to the path below.

Next

End if
%>

The code you have posted for it is the uploader class itself.....
0

Author Comment

now in my upload.asp file I did the following:

<HTML>
<BODY>
<input TYPE="file" NAME="blob" class="input" size="20">
</form>
</body>
</html>

and when I attemp to upload a file and check my web server db folder, I see a file name db, 0 kb in size.
0

LVL 25

Expert Comment

<%

If Request.TotalBytes > 0 Then

For lngLoop = 0 to objUpload.Files.Count - 1
'the internet guest account must have
'write permission to the path below.

Next

End if
%>

and you can get rid of the <!-- #include file="fileUpload.asp" --> on your form page
0

Author Comment

I came up with the fileupload.asp file a little different than the one shown on the website as in:

<SCRIPT LANGUAGE=vbscript RUNAT=Server>

Private Sub Class_Initialize()
call RequestBin()
End Sub

function RequestBin()

Dim PosBegin, PosEnd
PosBegin = 1
PosEnd = InStrB(1,RequestBin,getByte(chr(13)))

If PosEnd > 0 then
boundary = MidB(RequestBin,PosBegin,PosEnd-PosBegin)
boundaryPos = InStrB(PosBegin,RequestBin,boundary)
End If

If boundary = "" then

PosEnd = InStrB(PosBegin,RequestBin,getByte(chr("&")))

Do While PosBegin < LenB(RequestBin)
Temp = getString(MidB(RequestBin,PosBegin,PosEnd-PosBegin))
tempPos = InStr(PosBegin,Temp,"=")
Name = URLDecode(Left(Temp,tempPos-PosBegin))
Value = URLDecode(Right(Temp,Len(Temp)-tempPos))
PosBegin = PosEnd + 1
PosEnd = InStrB(PosBegin,RequestBin,getByte(chr("&")))
If PosEnd = 0 then PosEnd = LenB(RequestBin) + 1
Loop
Else
Do Until(boundaryPos=InStrB(RequestBin,boundary & getByte("--")))
Pos = InStrB(boundaryPos,RequestBin,getByte("Content-Disposition"))
Pos = InStrB(Pos,RequestBin,getByte("name="))
PosBegin = Pos + 6
PosEnd = InStrB(PosBegin,RequestBin,getByte(chr(34)))
Name = getString(MidB(RequestBin,PosBegin,PosEnd-PosBegin))
Pos = InStrB(boundaryPos,RequestBin,getByte("filename="))
boundaryPos = MidB(PosBegin,RequestBin,boundary)
If Pos <> 0 AND (Pos<boundaryPos) Then
PosBegin = Pos + 10
PosEnd = InStrB(PosBegin,RequestBin,getByte(chr(34)))
FileName = getString(MidB(RequestBin,PosBegin,PosEnd-PosBegin))
Pos = InStrB(boundaryPos,RequestBin,getByte("Content-Type:"))
PosBegin = Pos + 14
PosEnd = InStrB(PosBegin,RequestBin,getByte(chr(13)))
ContentType = getString(MidB(RequestBin,PosBegin,PosEnd-PosBegin))
PosBegin = Pos + 4
PosEnd = InStrB(PosBegin,RequestBin,boundaryPos) - 2
Value = getString(MidB(RequestBin,PosBegin,PosEnd-PosBegin))
Else
boundaryPos=InstrB(boundaryPos+LenB(boundary),RequestBin,boundary)
End If
Loop
End if

End function

function URLDecode(sText)

sDecoded = sText
Set oRegExpr = Server.CreateObject("VBScript.RegExp")
oRegExpr.Pattern = "%[0-9,A-F]{2}"
oRegExpr.Global = True
Set oMatchCollection = oRegExpr.Execute(sText)
For Each oMatch In oMatchCollection
sDecoded = Replace(sDecoded,oMatch.value,Chr(CInt("&H" & Right(oMatch.Value,2))))
Next
URLDecode = sDecoded

End function

Function getString(StringBin)

getString =""
For intCount = 1 to LenB(StringBin)
getString = getString & chr(AscB(MidB(StringBin,intCount,1)))
Next

End Function

Function getByte(ByteBin)

getByte =""
For intCount = 1 to Len(ByteBin)
getByte = getByte & chrB(AscB(MidB(ByteBin,intCount,1)))
Next

End Function

End Class
</SCRIPT>

so using:

<%

If Request.TotalBytes > 0 Then

For lngLoop = 0 to objUpload.Files.Count - 1
'the internet guest account must have
'write permission to the path below.

Next

End if
%>

does not seem to work.
0

LVL 25

Expert Comment

ok, it looks like what you have done is converted it to VBA (visual basic for applications)

your best bet would be to use the original code that you downloaded, and use it exactly how they show to use it
0

LVL 25

Expert Comment

i don't really have any objections, but I would liked to have known the outcome
0

Accepted Solution

Closed, 80 points refunded.
GranMod
The Experts Exchange
Community Support Moderator of all Ages
0

## Featured Post

### Suggested Solutions

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…