Bookmarks

Yahoo Gmail Google Facebook Delicious Twitter Reddit Stumpleupon Myspace Digg

Search queries

w2ksp4.exe, WwwxxXdbf, procmail "FROM_MAILER" patch, Use of assignment to $[ is deprecated at /usr/local/sbin/apxs line 86. , wwwxxx vim, mysql closing table and opening table, 800c5000, setgid operation not permitted, pciehp: acpi_pciehprm on IBM, WWWXXX.DBF

Links

XODOX
Impressum

#1: ASP.Classic: File uploading...

Posted on 2008-04-08 19:14:37 by Blue Streak

Hi, folks!

I have scoured the Internet high and low trying to look trying to
find a simple example of uploading a file to a server using
ASP.Classic. After a lot of searching I think I have it distilled
down to its simplest form illustrated in my example. But, alas, it
doesn't work :/ Upon further investigation it turns out my example
coughs up 0 for Response.TotalBytes causing an error condition.

So, what am I missing?

TIA...

Client side (application.asp):
<form method="post" action="submission.asp">
-
-
<input type="file" name="myFile">
<input type="submit">
</form>

Server side (submission.asp):
<%
szFileName = "test.bin"
Set adStream = Server.CreateObject("ADODB.Stream")
adStream.Type = 1 'adTypeBinary
adStream.Open
adStream.Write(Response.BinaryRead(Response.TotalBytes))
adStream.SaveToFile(szFileName)
adStream.Close
%>

Report this message

#2: Re: ASP.Classic: File uploading...

Posted on 2008-04-08 19:16:35 by Blue Streak

On Apr 8, 1:14=A0pm, Blue Streak <rdlebre...@hotmail.com> wrote:
> Hi, folks!
>
> =A0 =A0 I have scoured the Internet high and low trying to look trying to
> find a simple example of uploading a file to a server using
> ASP.Classic. =A0After a lot of searching I think I have it distilled
> down to its simplest form illustrated in my example. =A0But, alas, it
> doesn't work :/ =A0Upon further investigation it turns out my example
> coughs up 0 for Response.TotalBytes causing an error condition.
>
> So, what am I missing?
>
> TIA...
>
> Client side (application.asp):
> <form method=3D"post" action=3D"submission.asp">
> -
> -
> <input type=3D"file" name=3D"myFile">
> <input type=3D"submit">
> </form>
>
> Server side (submission.asp):
> <%
> szFileName =3D "test.bin"
> Set adStream =3D Server.CreateObject("ADODB.Stream")
> adStream.Type =3D 1 'adTypeBinary
> adStream.Open
> adStream.Write(Response.BinaryRead(Response.TotalBytes))
> adStream.SaveToFile(szFileName)
> adStream.Close
> %>

I am testing these under WinXP:SP2 with IIS 5.1

Report this message

#3: Re: ASP.Classic: File uploading...

Posted on 2008-04-08 20:01:16 by reb01501

Blue Streak wrote:
> Hi, folks!
>
> I have scoured the Internet high and low trying to look trying to
> find a simple example of uploading a file to a server using
> ASP.Classic. After a lot of searching I think I have it distilled
> down to its simplest form illustrated in my example. But, alas, it
> doesn't work :/ Upon further investigation it turns out my example
> coughs up 0 for Response.TotalBytes causing an error condition.
>
> So, what am I missing?
>
> TIA...
>
> Client side (application.asp):
> <form method="post" action="submission.asp">
> -
> -
> <input type="file" name="myFile">
> <input type="submit">
> </form>
>

You missed the part where you tell the server that your submission is a
multipart/form-data submission.

<form method=POST name=form1 action=submission.asp
enctype='multipart/form-data'>
<input type=file name=filename>
<input type=submit value=' Go >> '>
</form>

See here for more information:
http://classicasp.aspfaq.com/forms/how-do-i-upload-files-fro m-the-client-to-the-server.html

--
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.

Report this message

#4: Re: ASP.Classic: File uploading...

Posted on 2008-04-08 20:18:09 by Blue Streak

On Apr 8, 2:01=A0pm, "Bob Barrows [MVP]" <reb01...@NOyahoo.SPAMcom>
wrote:
> Blue Streak wrote:
> > Hi, folks!
>
> > =A0 =A0 I have scoured the Internet high and low trying to look trying t=
o
> > find a simple example of uploading a file to a server using
> > ASP.Classic. =A0After a lot of searching I think I have it distilled
> > down to its simplest form illustrated in my example. =A0But, alas, it
> > doesn't work :/ =A0Upon further investigation it turns out my example
> > coughs up 0 for Response.TotalBytes causing an error condition.
>
> > So, what am I missing?
>
> > TIA...
>
> > Client side (application.asp):
> > <form method=3D"post" action=3D"submission.asp">
> > -
> > -
> > <input type=3D"file" name=3D"myFile">
> > <input type=3D"submit">
> > </form>
>
> You missed the part where you tell the server that your submission is a
> multipart/form-data submission.
>
> <form method=3DPOST name=3Dform1 action=3Dsubmission.asp
> enctype=3D'multipart/form-data'>
> =A0 =A0 <input type=3Dfile name=3Dfilename>
> =A0 =A0 <input type=3Dsubmit value=3D' Go >> '>
> </form>
>
> See here for more information:http://classicasp.aspfaq.com/forms/how-do-i-=
upload-files-from-the-cli...
>
> --
> 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.- Hide quoted text -
>
> - Show quoted text -

D'oh!

Thanks.

Report this message

#5: Re: ASP.Classic: File uploading...

Posted on 2008-04-08 20:19:43 by paulrichardbaker

And shouldn't that be Request.TotalBytes?

You will get poor performance that could impact the whole server with large
files, because ASP is buffering the request in memory and then you're coping
it into memory as well. Here is a newsgroup post that discusses that.

Large file upload/download using IIS:
http://groups.google.com/group/microsoft.public.inetserver.i is/browse_thread/thread/e99f6592b55af061

Paul

"Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
news:%23lh2LKamIHA.4140@TK2MSFTNGP04.phx.gbl...
> Blue Streak wrote:
>> Hi, folks!
>>
>> I have scoured the Internet high and low trying to look trying to
>> find a simple example of uploading a file to a server using
>> ASP.Classic. After a lot of searching I think I have it distilled
>> down to its simplest form illustrated in my example. But, alas, it
>> doesn't work :/ Upon further investigation it turns out my example
>> coughs up 0 for Response.TotalBytes causing an error condition.
>>
>> So, what am I missing?
>>
>> TIA...
>>
>> Client side (application.asp):
>> <form method="post" action="submission.asp">
>> -
>> -
>> <input type="file" name="myFile">
>> <input type="submit">
>> </form>
>>
>
> You missed the part where you tell the server that your submission is a
> multipart/form-data submission.
>
> <form method=POST name=form1 action=submission.asp
> enctype='multipart/form-data'>
> <input type=file name=filename>
> <input type=submit value=' Go >> '>
> </form>
>
> See here for more information:
> http://classicasp.aspfaq.com/forms/how-do-i-upload-files-fro m-the-client-to-the-server.html
>
> --
> 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.
>
>

Report this message

#6: Re: ASP.Classic: File uploading...

Posted on 2008-04-08 20:29:40 by Blue Streak

On Apr 8, 2:19=A0pm, "Paul Baker [MVP, Windows Desktop Experience]"
<paulrichardba...@community.nospam> wrote:
> And shouldn't that be Request.TotalBytes?
>
> You will get poor performance that could impact the whole server with larg=
e
> files, because ASP is buffering the request in memory and then you're copi=
ng
> it into memory as well. Here is a newsgroup post that discusses that.
>
> Large file upload/download using IIS:http://groups.google.com/group/micros=
oft.public.inetserver.iis/browse...
>
> Paul
>
> "Bob Barrows [MVP]" <reb01...@NOyahoo.SPAMcom> wrote in messagenews:%23lh2=
LKamIHA.4140@TK2MSFTNGP04.phx.gbl...
>
>
>
> > Blue Streak wrote:
> >> Hi, folks!
>
> >> =A0 =A0 I have scoured the Internet high and low trying to look trying =
to
> >> find a simple example of uploading a file to a server using
> >> ASP.Classic. =A0After a lot of searching I think I have it distilled
> >> down to its simplest form illustrated in my example. =A0But, alas, it
> >> doesn't work :/ =A0Upon further investigation it turns out my example
> >> coughs up 0 for Response.TotalBytes causing an error condition.
>
> >> So, what am I missing?
>
> >> TIA...
>
> >> Client side (application.asp):
> >> <form method=3D"post" action=3D"submission.asp">
> >> -
> >> -
> >> <input type=3D"file" name=3D"myFile">
> >> <input type=3D"submit">
> >> </form>
>
> > You missed the part where you tell the server that your submission is a
> > multipart/form-data submission.
>
> > <form method=3DPOST name=3Dform1 action=3Dsubmission.asp
> > enctype=3D'multipart/form-data'>
> > =A0 =A0<input type=3Dfile name=3Dfilename>
> > =A0 =A0<input type=3Dsubmit value=3D' Go >> '>
> > </form>
>
> > See here for more information:
> >http://classicasp.aspfaq.com/forms/how-do-i-upload-files-fr om-the-cli...
>
> > --
> > 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.- Hide quoted text -
>
> - Show quoted text -

Oh, yeah... D'oh!

Report this message

#7: Re: ASP.Classic: File uploading...

Posted on 2008-04-08 20:34:18 by reb01501

Paul Baker [MVP, Windows Desktop Experience] wrote:
> And shouldn't that be Request.TotalBytes?
>
> You will get poor performance

I can't argue with that. It's discussed in the article I linked to.
--
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.

Report this message

#8: RE: ASP.Classic: File uploading...

Posted on 2008-04-08 21:32:00 by BDJJ

If at all possible do it with a simple .NET page (called from your Classic
ASP page) - it's simple, clean, and fast - Classic ASP, I found, is terrible
for file uploads. Looks like everyone answered your OP so I won't add my 2
cents worth.

"Blue Streak" wrote:

> Hi, folks!
>
> I have scoured the Internet high and low trying to look trying to
> find a simple example of uploading a file to a server using
> ASP.Classic. After a lot of searching I think I have it distilled
> down to its simplest form illustrated in my example. But, alas, it
> doesn't work :/ Upon further investigation it turns out my example
> coughs up 0 for Response.TotalBytes causing an error condition.
>
> So, what am I missing?
>
> TIA...
>
> Client side (application.asp):
> <form method="post" action="submission.asp">
> -
> -
> <input type="file" name="myFile">
> <input type="submit">
> </form>
>
> Server side (submission.asp):
> <%
> szFileName = "test.bin"
> Set adStream = Server.CreateObject("ADODB.Stream")
> adStream.Type = 1 'adTypeBinary
> adStream.Open
> adStream.Write(Response.BinaryRead(Response.TotalBytes))
> adStream.SaveToFile(szFileName)
> adStream.Close
> %>
>

Report this message

#9: Re: ASP.Classic: File uploading...

Posted on 2008-04-08 22:23:23 by Blue Streak

On Apr 8, 3:32=A0pm, B@DJJ <B...@discussions.microsoft.com> wrote:
> If at all possible do it with a simple .NET page (called from your Classic=

> ASP page) - it's simple, clean, and fast - Classic ASP, I found, is terrib=
le
> for file uploads. =A0Looks like everyone answered your OP so I won't add m=
y 2
> cents worth.
>
>
>
> "Blue Streak" wrote:
> > Hi, folks!
>
> > =A0 =A0 I have scoured the Internet high and low trying to look trying t=
o
> > find a simple example of uploading a file to a server using
> > ASP.Classic. =A0After a lot of searching I think I have it distilled
> > down to its simplest form illustrated in my example. =A0But, alas, it
> > doesn't work :/ =A0Upon further investigation it turns out my example
> > coughs up 0 for Response.TotalBytes causing an error condition.
>
> > So, what am I missing?
>
> > TIA...
>
> > Client side (application.asp):
> > <form method=3D"post" action=3D"submission.asp">
> > -
> > -
> > <input type=3D"file" name=3D"myFile">
> > <input type=3D"submit">
> > </form>
>
> > Server side (submission.asp):
> > <%
> > szFileName =3D "test.bin"
> > Set adStream =3D Server.CreateObject("ADODB.Stream")
> > adStream.Type =3D 1 'adTypeBinary
> > adStream.Open
> > adStream.Write(Response.BinaryRead(Response.TotalBytes))
> > adStream.SaveToFile(szFileName)
> > adStream.Close
> > %>- Hide quoted text -
>
> - Show quoted text -

That may be true but this host doesn't support ASP.NET.

I dunno why. I'm just helping a friend and he said ASP.Classic.

Report this message

#10: Re: ASP.Classic: File uploading...

Posted on 2008-04-09 08:27:19 by Egbert Nierop

"Blue Streak" <rdlebreton@hotmail.com> wrote in message
news:09aacf28-d97c-440f-8860-fdb31f4eaa31@z38g2000hsc.google groups.com...
On Apr 8, 3:32 pm, B@DJJ <B...@discussions.microsoft.com> wrote:
> If at all possible do it with a simple .NET page (called from your Classic
> ASP page) - it's simple, clean, and fast - Classic ASP, I found, is
> terrible
> for file uploads. Looks like everyone answered your OP so I won't add my 2
> cents worth.
>
>
>
> "Blue Streak" wrote:
> > Hi, folks!
>
> > I have scoured the Internet high and low trying to look trying to
> > find a simple example of uploading a file to a server using
> > ASP.Classic. After a lot of searching I think I have it distilled
> > down to its simplest form illustrated in my example. But, alas, it
> > doesn't work :/ Upon further investigation it turns out my example
> > coughs up 0 for Response.TotalBytes causing an error condition.
>
> > So, what am I missing?
>
> > TIA...
>
> > Client side (application.asp):
> > <form method="post" action="submission.asp">
> > -
> > -
> > <input type="file" name="myFile">
> > <input type="submit">
> > </form>
>
> > Server side (submission.asp):
> > <%
> > szFileName = "test.bin"
> > Set adStream = Server.CreateObject("ADODB.Stream")
> > adStream.Type = 1 'adTypeBinary
> > adStream.Open
> > adStream.Write(Response.BinaryRead(Response.TotalBytes))
> > adStream.SaveToFile(szFileName)
> > adStream.Close
> > %>- Hide quoted text -
>
> - Show quoted text -

If it's about small downloads, not for professional usage this script below
can work.



<?xml version="1.0" encoding="utf-8"?>
<?component debug="false" error="false" ?>
<component>

<object id="ASPForm" progid="Scripting.Dictionary"/>
<registration
description="Upload file via ASP"
progid="adUpload.WSC"
version="1.00"
classid="{f91cef0f-789d-4106-af7e-e6304e883969}"
>
</registration>

<public>
<method name="ProcessForm">
<parameter name="Request"/>
</method>
</public>

<!-- this is shared code completely made by Egbert Nierop. ADC Cure, author
of ASP Session
http://www.nieropwebconsult.nl/asp_session_manager.htm

NO garantuees, NO support, usage is your OWN risk.
Do not use for bigger files than: say 1MB. Otherwise you'll break down your
IIS server because of CPU stress.

Usage within your ASP:
<%
Set YourForm = Server.CreateObject("adUpload.WSC")
after using this component, Request.Form does NOT work anymore
when your HTML form contains several elements with the same name
for instance "category" you would get it back as array

Set aspForm = YourForm.ProcessForm(Request)

cat1 = YourForm("category")(0)
cat2 = YourForm("category")(1)

'this would be your image info
yourbinarysource = YourForm("fileuploadfield")(0)
yourContentType = YourForm("fileuploadfield")(1)
yourImage = YourForm("fileuploadfield")(2)

sample HTML
<FORM action="yourasp.asp" method="POST" enctype="multipart/form-data">
<INPUT TYPE=TEXT NAME="category">
<INPUT TYPE=TEXT NAME="category">
<INPUT TYPE=FILE NAME="fileuploadfield">
</FORM>
Not recommanded for heavy use since character conversion (ANSI-UNICODE)
still not
can be done in vbscript natively

-->
<script language="vbscript">
<![CDATA[

' Script provided by ADC Cure, author of ISP Session management for ASP.

Const INVALID_HEADER = "Invalid data sent; please use a valid recent
browser", FORM_DATA = "Content-Disposition:"
Const vbUnicode = 64



'pass through the Request object!
'it could have been done by using the mtxas.appserver.1 component but
'why should I?
Function ProcessForm (Request)
'Stop decomment to debug
Dim varBlock, strMulti, bytePtr, endPtr, byteCrLf, Matches, Match, _
varFormFields, tempSplit, tempArr, _
strFieldName, binImage, strAttachName, strAttachType, _
blnOK, blnMultiple, ubnd, lastEl, tempVal, _
Reggie, LineCounter, blnNoAttach, begPtr, wordCounter, vTotal
CONST CHUNKSIZE = 2048
'this is a byte array
If Request.ServerVariables("HTTP_METHOD") <> "POST" Then Exit Function
vTotal = Request.TotalBytes


varBlock = Request.BinaryRead(vTotal)


byteCrLf = ChrB(13) + ChrB(10)

bytePtr = InstrB(1, varBlock, byteCrLf)

If BytePtr = 0 Then
Err.Raise 5,"INVALID_HEADER"
Exit Function
End If
strMulti = LeftB(varBlock, bytePtr - 1) ' exclusief CrLf

varFormFields = SplitB(varBlock, strMulti)
varBlock = Null
If IsEmpty(varFormFields) Then Exit Function

'line 0 is empty because the POST begins with the strMulti delimiter and
split
'sees that as an empty element
Set Reggie = New RegExp
ubnd = UBound(varFormFields)

For x = 1 To ubnd

' we split 3 lines. Binary file uploads have 4 lines!
' when the 3trd line is empty
' byte 0 and 1 is CrLf because of the very first strMulti + CrLf
' the very last line is strMulti + "--" + CrLf; this is just the RFC...
bytePtr = 3
lineCounter = 0
blnOK = True
blnNoAttach = False
blnMultiple = False
Do
begPtr = InstrB(bytePtr, varFormFields(x), byteCrLf)
If begPtr = 0 Then
tempSplit = MidB(varFormFields(x), bytePtr)
Else
tempSplit = MidB(varFormFields(x), bytePtr, begPtr - bytePtr)
End If
bytePtr = begPtr + LenB(byteCrLf)
lineCounter = lineCounter + 1
wordCounter = 0

Select Case lineCounter
Case 1 'Form-data section
Reggie.Pattern = "[a-zA-Z0-9 \\\.\-:]+"
Reggie.IgnoreCase = False
Reggie.Global = True
Set Matches = Reggie.Execute(SlowConv(tempSplit))
For Each Match in Matches
Select Case wordCounter
Case 0
If RTrim(Match.Value) <> "Content-Disposition: form-data" Then
blnOK = false
End If
Case 1
If Trim(Match.Value) <> "name" Then
blnOK = False
End If
Case 2
strFieldName = Match.Value
'if strFieldName = "BannerID" Then Stop
If ASPForm.Exists(strFieldName) Then
' if first time here convert it to an array
tempVal = ASPForm.Item(strFieldName)
If Not IsArray(tempVal) Then
Redim tempArr(0)
tempArr(0) = tempVal
ASPForm.Item(strFieldName) = tempArr
End If
blnMultiple = True
Else
ASPForm.Add strFieldName, Empty
End If
If Match.Length > 32 Or Match.Length = 0 Then
blnOK = false
End If
Case 3
If Trim(Match.Value) <> "filename" Then
blnOK = false
End If
Case 4
strAttachName = Match.Value
If Len(strAttachName) = 0 Then blnOK = False
End Select
wordCounter = wordCounter + 1
Next
blnNoAttach = (wordCounter = 3)
Case 2 'Content-Type section OR empty (defines end of headers)
If blnNoAttach = True Then
'er moet een waarde staan If LenB(tempSplit) = 0 Then
If (begPtr - bytePtr) <> -2 Then
blnOK = false
End If
Else
'Stop
sContentType = SlowConv(tempSplit)
strAttachType = sContentType
Select Case sContentType
Case "Content-Type: image/gif"
Case "Content-Type: image/jpeg"
Case "Content-Type: image/pjpeg"
Case "Content-Type: text/html"
Case "Content-Type: image/png"
Case Else
'not supported
' Stop
blnOK = false
strAttachType = Empty
End Select
End If
Case 3 'empty when image otherwise formfield data

If blnNoAttach = True Then
If blnMultiple Then
tempArr = ASPForm.Item(strFieldName)
lastEl = UBound(tempArr) + 1
Redim Preserve tempArr(lastEl)
temparr(lastEl) = SlowConv(tempSplit)
ASPForm.Item(strFieldName) = tempArr
Else
ASPForm.Item(strFieldName) = SlowConv(tempSplit)
End If
Exit Do
' if attachment the value MUST be null If LenB(tempSplit) = 0 Then
ElseIf LenB(tempSplit) > 0 Then
blnOK = false
Else
'Stop
' take the rest of the data until the last byte!
ReDim arrtemp(2)
arrTemp(0) = strAttachName
arrTemp(1) = strAttachType
arrTemp(2) = MidB(varFormFields(x), bytePtr)
'Stop
ASPForm.Item(strFieldName) = arrTemp
Exit Do
End If
End Select
Loop While blnOK
Next
Set ProcessForm = ASPForm

End Function

'slow! I hope MS will provide a strconv function for vbscript.
'Otherwise a MidB statement instead of function would also help
Function SlowConv(sString)
Dim lLen, cx
For cx = 1 To LenB(sString)
SlowConv = SlowConv + ChrW(AscB(MidB(sString, cx, 1)))
Next
End Function




' this has been written because the Split function sucks for byte strings
Function SplitB(expr, splitExpr)
Dim lastel, arrTemp, begPtr, bytePtr, spCount, lenExpr

If IsEmpty(expr) Or IsNull(expr) Or IsEmpty(splitExpr) Or
IsNull(splitExpr) Then
Exit Function
End If
' Stop


lastel = 0
lenExpr = Len(splitExpr)
bytePtr = 1

Do
byteptr = InStrB(byteptr, expr, splitexpr)
If byteptr = 0 Then Exit Do
spcount = spcount + 1
byteptr = byteptr + lenexpr
Loop
Redim arrTemp(spCount)
bytePtr = 1
Do
begPtr = InStrB(bytePtr, expr, splitExpr)
If begPtr = 0 Then
arrTemp(lastel) = MidB(expr, bytePtr)
Exit Do
Else
arrTemp(lastel) = MidB(expr, bytePtr, begPtr - bytePtr)
End If
bytePtr = begPtr + LenB(splitExpr)
lastel = lastel + 1
Loop

SplitB = arrTemp

End Function

]]>
</script>

</component>

Report this message