By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,843 Members | 864 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,843 IT Pros & Developers. It's quick & easy.

Cannot use Request.Form

P: n/a
Hi!

I get an error when I run my code
Is there any other way to get te information from my form?

Heres the error I get and the code beneath.
Line 120 is market with ''''''''''''Line 120'''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''
'''''''''''''''''''CODE''''''''''''''''''''''''''' ''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''

Request object error 'ASP 0207 : 80004005'
Cannot use Request.Form

/asp/admin/select_image.asp, line 120

Cannot use Request.Form collection after calling BinaryRead.

'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''
'''''''''''''''''''CODE''''''''''''''''''''''''''' ''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''

if Request.QueryString("action") = "upload" then
Server.ScriptTimeout = 1200
Response.Expires = 0
Response.Buffer = TRUE
Response.Clear

Dim UploadRequest
Set UploadRequest = CreateObject("Scripting.Dictionary")

ByteCount = Request.TotalBytes

if ByteCount > Application("MaxFileSize2Upload") then
Response.Redirect "./select_image.asp?error=05"
end if
RequestBin = Request.BinaryRead(byteCount)
BuildUploadRequest RequestBin

Dim aux, aux1
Dim ImageCateg, ContentType, FilePathName, FileName, Value

ImageCateg = Unescape(UploadRequest.Item("inpcatid").Item("Valu e")) 'Image
Folder

on error resume next
ContentType = UploadRequest.Item("inpFile").Item("ContentType")
FILEFLAG = err.number
on error goto 0

if FILEFLAG = 0 then
ContentType = UploadRequest.Item("inpFile").Item("ContentType")
FilePathName = UploadRequest.Item("inpFile").Item("FileName")
FileName =
Right(filepathname,Len(filepathname)-InstrRev(filepathname,"\"))
Value = UploadRequest.Item("inpFile").Item("Value")
else
FileName = ""
end if

Dim objFSO2
Dim objFSO3
Dim objUploadFile
Dim objDelFile1
Dim OldPath
'''''''''''''''laster opp bilde'''''''''''''''''''''''''''''
if FileName<>"" then
on error resume next
Set objFSO2 = Server.CreateObject("Scripting.FileSystemObject")
Set objUploadFile = objFSO2.CreateTextFile(ImageCateg&"\"&FileName)
objUploadFile.Write getString(value)
objUploadFile.Close
FILEFLAG = err.number
on error goto 0
'''''''''''''''resizer bilde'''''''''''''''''''''''''''''
' create instance of AspJpeg object
Set jpeg = Server.CreateObject("Persits.Jpeg")

' open uploaded file
Dim ResizeName
Dim Ratio
OldPath = Server.MapPath(Escape(sDir) & Escape(FileName))
jpeg.Open( OldPath )
' resize image accoring to "scale" option.

'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''
'''''''''Line
120''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''
Select Case Request.Form("resize")

'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''
'''''''''/Line
120/'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''
''''''''''''''''''''''''''''''''''
Case "tn"
ResizeName = "_miniatyr"
Ratio = jpeg.OriginalHeight / 100
jpeg.Width = 100
jpeg.Height = jpeg.OriginalHeight / Ratio
Case Else
ResizeName = "_noko_anna"
jpeg.Width = jpeg.OriginalWidth * 50 / 100
jpeg.Height = jpeg.OriginalHeight * 50 / 100
End Select
OldPath = Server.MapPath(Escape(sDir)) & "\" & Escape(FileName)
SavePath = Left(OldPath, InStrRev(OldPath, ".") - 1)
SavePath = SavePath & ResizeName
SavePath = SavePath & ".jpg"
Jpeg.Interpolation = 2
'AspJpeg always generates JPEG thumbnails regardless of original format.
'If the original file was not a JPEG, append .JPG extension.

jpeg.Save SavePath
end if

Set objFSO2 = nothing
Set objUploadFile = nothing
Set UploadRequest = nothing

Jul 19 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
BinaryRead and Request.Form/QueryString are mutually exclusive. Once you
have used one to read the data, the other is inaccessible.

I found an article on the MSDN library about how to recreate a
pseudo-Request.Form collection but its taken from Active Server Developer's
Journal, so I'm not sure if its on the web. I'll see if I can find a web
article on this, otherwise I'll have a read through the article and give you
the basics here.

A Ratcliffe
ar********@archimagic.net

"Christopher Brandsdal" <ch***********@c2i.net> wrote in message
news:OG**************@tk2msftngp13.phx.gbl...
Hi!

I get an error when I run my code
Is there any other way to get te information from my form?

Heres the error I get and the code beneath.
Line 120 is market with ''''''''''''Line 120'''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''' '''''''''''''''''''CODE''''''''''''''''''''''''''' '''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''

Request object error 'ASP 0207 : 80004005'
Cannot use Request.Form

/asp/admin/select_image.asp, line 120

Cannot use Request.Form collection after calling BinaryRead.

'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''' '''''''''''''''''''CODE''''''''''''''''''''''''''' '''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''

if Request.QueryString("action") = "upload" then
Server.ScriptTimeout = 1200
Response.Expires = 0
Response.Buffer = TRUE
Response.Clear

Dim UploadRequest
Set UploadRequest = CreateObject("Scripting.Dictionary")

ByteCount = Request.TotalBytes

if ByteCount > Application("MaxFileSize2Upload") then
Response.Redirect "./select_image.asp?error=05"
end if
RequestBin = Request.BinaryRead(byteCount)
BuildUploadRequest RequestBin

Dim aux, aux1
Dim ImageCateg, ContentType, FilePathName, FileName, Value

ImageCateg = Unescape(UploadRequest.Item("inpcatid").Item("Valu e")) 'Image Folder

on error resume next
ContentType = UploadRequest.Item("inpFile").Item("ContentType")
FILEFLAG = err.number
on error goto 0

if FILEFLAG = 0 then
ContentType = UploadRequest.Item("inpFile").Item("ContentType")
FilePathName = UploadRequest.Item("inpFile").Item("FileName")
FileName =
Right(filepathname,Len(filepathname)-InstrRev(filepathname,"\"))
Value = UploadRequest.Item("inpFile").Item("Value")
else
FileName = ""
end if

Dim objFSO2
Dim objFSO3
Dim objUploadFile
Dim objDelFile1
Dim OldPath
'''''''''''''''laster opp bilde'''''''''''''''''''''''''''''
if FileName<>"" then
on error resume next
Set objFSO2 = Server.CreateObject("Scripting.FileSystemObject")
Set objUploadFile = objFSO2.CreateTextFile(ImageCateg&"\"&FileName)
objUploadFile.Write getString(value)
objUploadFile.Close
FILEFLAG = err.number
on error goto 0
'''''''''''''''resizer bilde'''''''''''''''''''''''''''''
' create instance of AspJpeg object
Set jpeg = Server.CreateObject("Persits.Jpeg")

' open uploaded file
Dim ResizeName
Dim Ratio
OldPath = Server.MapPath(Escape(sDir) & Escape(FileName))
jpeg.Open( OldPath )
' resize image accoring to "scale" option.

'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''' '''''''''Line
120''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''
Select Case Request.Form("resize")

'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''' '''''''''/Line
120/'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''' ''''''''''''''''''''''''''''''''''
Case "tn"
ResizeName = "_miniatyr"
Ratio = jpeg.OriginalHeight / 100
jpeg.Width = 100
jpeg.Height = jpeg.OriginalHeight / Ratio
Case Else
ResizeName = "_noko_anna"
jpeg.Width = jpeg.OriginalWidth * 50 / 100
jpeg.Height = jpeg.OriginalHeight * 50 / 100
End Select
OldPath = Server.MapPath(Escape(sDir)) & "\" & Escape(FileName)
SavePath = Left(OldPath, InStrRev(OldPath, ".") - 1)
SavePath = SavePath & ResizeName
SavePath = SavePath & ".jpg"
Jpeg.Interpolation = 2
'AspJpeg always generates JPEG thumbnails regardless of original format. 'If the original file was not a JPEG, append .JPG extension.

jpeg.Save SavePath
end if

Set objFSO2 = nothing
Set objUploadFile = nothing
Set UploadRequest = nothing

Jul 19 '05 #2

P: n/a
Thanks for helping me!

I think it's possible because AspUpload can do it.

I have AspJpeg installed on my server but NOT AspUpload.
Here is a short AspJpeg script that use something else than Request.Form:

<HTML>
<HEAD>
<TITLE>AspJpeg 1.2 - Upload.asp</TITLE>
</HEAD>
<BODY>

<!-- this script is invoked by form.asp-->
<%
' Create an instance of AspUpload object
Set Upload = Server.CreateObject("Persits.Upload")

' Capture uploaded file. Save returns the number of files uploaded
Count = Upload.Save(Server.MapPath("/"))

If Count = 0 Then
Response.Write "No images selected. <A HREF=""form.asp"">Try again</A>."
Response.End
Else

' Obtain File object representing uploaded file
Set File = Upload.Files(1)

' Is this a valid image file?
If File.ImageType <> "UNKNOWN" Then

' create instance of AspJpeg object
Set jpeg = Server.CreateObject("Persits.Jpeg")

' open uploaded file
jpeg.Open( File.Path )

' resize image accoring to "scale" option.
' notice that we cannot use Request.Form, so we use Upload.Form instead.
jpeg.Width = jpeg.OriginalWidth * Upload.Form("scale") / 100
jpeg.Height = jpeg.OriginalHeight * Upload.Form("scale") / 100

SavePath = Server.MapPath("/bilde/") & File.ExtractFileName

' AspJpeg always generates JPEG thumbnails regardless of original format.
' If the original file was not a JPEG, append .JPG extension.
If UCase(Right(SavePath, 3)) <> "JPG" Then
SavePath = SavePath & ".jpg"
End If

jpeg.Save SavePath

Response.Write "Success! Both the original file and its thumbnail are
saved in the database.<P>"
Response.Write "Copies can be found at <B>c:\upload\" &
File.ExtractFileName & "</B> and <B>" & SavePath & "</B>"

Else
Response.Write "This is not a valid image. <A HREF=""form.asp"">Try
again</A>."
Response.End
End If
End If
%>
</BODY>
</HTML>

"A Ratcliffe" <ar********@archimagic.net> skrev i melding
news:eJ**************@TK2MSFTNGP09.phx.gbl...
BinaryRead and Request.Form/QueryString are mutually exclusive. Once you
have used one to read the data, the other is inaccessible.

I found an article on the MSDN library about how to recreate a
pseudo-Request.Form collection but its taken from Active Server Developer's Journal, so I'm not sure if its on the web. I'll see if I can find a web
article on this, otherwise I'll have a read through the article and give you the basics here.

A Ratcliffe
ar********@archimagic.net

"Christopher Brandsdal" <ch***********@c2i.net> wrote in message
news:OG**************@tk2msftngp13.phx.gbl...
Hi!

I get an error when I run my code
Is there any other way to get te information from my form?

Heres the error I get and the code beneath.
Line 120 is market with ''''''''''''Line 120'''''''''''''''''''''

'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''

'''''''''''''''''''CODE''''''''''''''''''''''''''' ''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''

Request object error 'ASP 0207 : 80004005'
Cannot use Request.Form

/asp/admin/select_image.asp, line 120

Cannot use Request.Form collection after calling BinaryRead.

'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''

'''''''''''''''''''CODE''''''''''''''''''''''''''' ''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''

if Request.QueryString("action") = "upload" then
Server.ScriptTimeout = 1200
Response.Expires = 0
Response.Buffer = TRUE
Response.Clear

Dim UploadRequest
Set UploadRequest = CreateObject("Scripting.Dictionary")

ByteCount = Request.TotalBytes

if ByteCount > Application("MaxFileSize2Upload") then
Response.Redirect "./select_image.asp?error=05"
end if
RequestBin = Request.BinaryRead(byteCount)
BuildUploadRequest RequestBin

Dim aux, aux1
Dim ImageCateg, ContentType, FilePathName, FileName, Value

ImageCateg = Unescape(UploadRequest.Item("inpcatid").Item("Valu e"))

'Image
Folder

on error resume next
ContentType = UploadRequest.Item("inpFile").Item("ContentType")
FILEFLAG = err.number
on error goto 0

if FILEFLAG = 0 then
ContentType = UploadRequest.Item("inpFile").Item("ContentType")
FilePathName = UploadRequest.Item("inpFile").Item("FileName")
FileName =
Right(filepathname,Len(filepathname)-InstrRev(filepathname,"\"))
Value = UploadRequest.Item("inpFile").Item("Value")
else
FileName = ""
end if

Dim objFSO2
Dim objFSO3
Dim objUploadFile
Dim objDelFile1
Dim OldPath
'''''''''''''''laster opp bilde'''''''''''''''''''''''''''''
if FileName<>"" then
on error resume next
Set objFSO2 = Server.CreateObject("Scripting.FileSystemObject")
Set objUploadFile = objFSO2.CreateTextFile(ImageCateg&"\"&FileName)
objUploadFile.Write getString(value)
objUploadFile.Close
FILEFLAG = err.number
on error goto 0
'''''''''''''''resizer bilde'''''''''''''''''''''''''''''
' create instance of AspJpeg object
Set jpeg = Server.CreateObject("Persits.Jpeg")

' open uploaded file
Dim ResizeName
Dim Ratio
OldPath = Server.MapPath(Escape(sDir) & Escape(FileName))
jpeg.Open( OldPath )
' resize image accoring to "scale" option.

'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''
'''''''''Line

120''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''
Select Case Request.Form("resize")

'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''
'''''''''/Line

120/'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''
''''''''''''''''''''''''''''''''''
Case "tn"
ResizeName = "_miniatyr"
Ratio = jpeg.OriginalHeight / 100
jpeg.Width = 100
jpeg.Height = jpeg.OriginalHeight / Ratio
Case Else
ResizeName = "_noko_anna"
jpeg.Width = jpeg.OriginalWidth * 50 / 100
jpeg.Height = jpeg.OriginalHeight * 50 / 100
End Select
OldPath = Server.MapPath(Escape(sDir)) & "\" & Escape(FileName)
SavePath = Left(OldPath, InStrRev(OldPath, ".") - 1)
SavePath = SavePath & ResizeName
SavePath = SavePath & ".jpg"
Jpeg.Interpolation = 2
'AspJpeg always generates JPEG thumbnails regardless of original

format.
'If the original file was not a JPEG, append .JPG extension.

jpeg.Save SavePath
end if

Set objFSO2 = nothing
Set objUploadFile = nothing
Set UploadRequest = nothing


Jul 19 '05 #3

P: n/a
It's definitely possible (the article I mentioned shows how to do so, which
is probably how ASPUpload does it).

"Christopher Brandsdal" <ch***********@c2i.net> wrote in message
news:u3*************@TK2MSFTNGP10.phx.gbl...
Thanks for helping me!

I think it's possible because AspUpload can do it.

I have AspJpeg installed on my server but NOT AspUpload.
Here is a short AspJpeg script that use something else than Request.Form:

<HTML>
<HEAD>
<TITLE>AspJpeg 1.2 - Upload.asp</TITLE>
</HEAD>
<BODY>

<!-- this script is invoked by form.asp-->
<%
' Create an instance of AspUpload object
Set Upload = Server.CreateObject("Persits.Upload")

' Capture uploaded file. Save returns the number of files uploaded
Count = Upload.Save(Server.MapPath("/"))

If Count = 0 Then
Response.Write "No images selected. <A HREF=""form.asp"">Try again</A>."
Response.End
Else

' Obtain File object representing uploaded file
Set File = Upload.Files(1)

' Is this a valid image file?
If File.ImageType <> "UNKNOWN" Then

' create instance of AspJpeg object
Set jpeg = Server.CreateObject("Persits.Jpeg")

' open uploaded file
jpeg.Open( File.Path )

' resize image accoring to "scale" option.
' notice that we cannot use Request.Form, so we use Upload.Form instead. jpeg.Width = jpeg.OriginalWidth * Upload.Form("scale") / 100
jpeg.Height = jpeg.OriginalHeight * Upload.Form("scale") / 100

SavePath = Server.MapPath("/bilde/") & File.ExtractFileName

' AspJpeg always generates JPEG thumbnails regardless of original format. ' If the original file was not a JPEG, append .JPG extension.
If UCase(Right(SavePath, 3)) <> "JPG" Then
SavePath = SavePath & ".jpg"
End If

jpeg.Save SavePath

Response.Write "Success! Both the original file and its thumbnail are
saved in the database.<P>"
Response.Write "Copies can be found at <B>c:\upload\" &
File.ExtractFileName & "</B> and <B>" & SavePath & "</B>"

Else
Response.Write "This is not a valid image. <A HREF=""form.asp"">Try
again</A>."
Response.End
End If
End If
%>
</BODY>
</HTML>

"A Ratcliffe" <ar********@archimagic.net> skrev i melding
news:eJ**************@TK2MSFTNGP09.phx.gbl...
BinaryRead and Request.Form/QueryString are mutually exclusive. Once you
have used one to read the data, the other is inaccessible.

I found an article on the MSDN library about how to recreate a
pseudo-Request.Form collection but its taken from Active Server

Developer's
Journal, so I'm not sure if its on the web. I'll see if I can find a web
article on this, otherwise I'll have a read through the article and give

you
the basics here.

A Ratcliffe
ar********@archimagic.net

"Christopher Brandsdal" <ch***********@c2i.net> wrote in message
news:OG**************@tk2msftngp13.phx.gbl...
Hi!

I get an error when I run my code
Is there any other way to get te information from my form?

Heres the error I get and the code beneath.
Line 120 is market with ''''''''''''Line 120'''''''''''''''''''''

'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''

'''''''''''''''''''CODE''''''''''''''''''''''''''' ''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''

Request object error 'ASP 0207 : 80004005'
Cannot use Request.Form

/asp/admin/select_image.asp, line 120

Cannot use Request.Form collection after calling BinaryRead.

'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''

'''''''''''''''''''CODE''''''''''''''''''''''''''' ''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''

if Request.QueryString("action") = "upload" then
Server.ScriptTimeout = 1200
Response.Expires = 0
Response.Buffer = TRUE
Response.Clear

Dim UploadRequest
Set UploadRequest = CreateObject("Scripting.Dictionary")

ByteCount = Request.TotalBytes

if ByteCount > Application("MaxFileSize2Upload") then
Response.Redirect "./select_image.asp?error=05"
end if
RequestBin = Request.BinaryRead(byteCount)
BuildUploadRequest RequestBin

Dim aux, aux1
Dim ImageCateg, ContentType, FilePathName, FileName, Value

ImageCateg = Unescape(UploadRequest.Item("inpcatid").Item("Valu e"))

'Image
Folder

on error resume next
ContentType = UploadRequest.Item("inpFile").Item("ContentType")
FILEFLAG = err.number
on error goto 0

if FILEFLAG = 0 then
ContentType = UploadRequest.Item("inpFile").Item("ContentType")
FilePathName = UploadRequest.Item("inpFile").Item("FileName")
FileName =
Right(filepathname,Len(filepathname)-InstrRev(filepathname,"\"))
Value = UploadRequest.Item("inpFile").Item("Value")
else
FileName = ""
end if

Dim objFSO2
Dim objFSO3
Dim objUploadFile
Dim objDelFile1
Dim OldPath
'''''''''''''''laster opp bilde'''''''''''''''''''''''''''''
if FileName<>"" then
on error resume next
Set objFSO2 = Server.CreateObject("Scripting.FileSystemObject")
Set objUploadFile = objFSO2.CreateTextFile(ImageCateg&"\"&FileName) objUploadFile.Write getString(value)
objUploadFile.Close
FILEFLAG = err.number
on error goto 0
'''''''''''''''resizer bilde'''''''''''''''''''''''''''''
' create instance of AspJpeg object
Set jpeg = Server.CreateObject("Persits.Jpeg")

' open uploaded file
Dim ResizeName
Dim Ratio
OldPath = Server.MapPath(Escape(sDir) & Escape(FileName))
jpeg.Open( OldPath )
' resize image accoring to "scale" option.

'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''
'''''''''Line

120''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''
Select Case Request.Form("resize")

'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''
'''''''''/Line

120/'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''
''''''''''''''''''''''''''''''''''
Case "tn"
ResizeName = "_miniatyr"
Ratio = jpeg.OriginalHeight / 100
jpeg.Width = 100
jpeg.Height = jpeg.OriginalHeight / Ratio
Case Else
ResizeName = "_noko_anna"
jpeg.Width = jpeg.OriginalWidth * 50 / 100
jpeg.Height = jpeg.OriginalHeight * 50 / 100
End Select
OldPath = Server.MapPath(Escape(sDir)) & "\" & Escape(FileName)
SavePath = Left(OldPath, InStrRev(OldPath, ".") - 1)
SavePath = SavePath & ResizeName
SavePath = SavePath & ".jpg"
Jpeg.Interpolation = 2
'AspJpeg always generates JPEG thumbnails regardless of original

format.
'If the original file was not a JPEG, append .JPG extension.

jpeg.Save SavePath
end if

Set objFSO2 = nothing
Set objUploadFile = nothing
Set UploadRequest = nothing



Jul 19 '05 #4

P: n/a
A quick glance at the web via serach engine found me this article. Its not
perfect in its explanations, but it does cover parsing your own Request.Form
data after a BinaryRead.

http://www.juicystudio.com/tutorial/asp/upload.html

HTH,

A Ratcliffe
ar********@archimagic.net

"A Ratcliffe" <ar********@archimagic.net> wrote in message
news:uw**************@TK2MSFTNGP09.phx.gbl...
It's definitely possible (the article I mentioned shows how to do so, which is probably how ASPUpload does it).

"Christopher Brandsdal" <ch***********@c2i.net> wrote in message
news:u3*************@TK2MSFTNGP10.phx.gbl...
Thanks for helping me!

I think it's possible because AspUpload can do it.

I have AspJpeg installed on my server but NOT AspUpload.
Here is a short AspJpeg script that use something else than Request.Form:

<HTML>
<HEAD>
<TITLE>AspJpeg 1.2 - Upload.asp</TITLE>
</HEAD>
<BODY>

<!-- this script is invoked by form.asp-->
<%
' Create an instance of AspUpload object
Set Upload = Server.CreateObject("Persits.Upload")

' Capture uploaded file. Save returns the number of files uploaded
Count = Upload.Save(Server.MapPath("/"))

If Count = 0 Then
Response.Write "No images selected. <A HREF=""form.asp"">Try again</A>." Response.End
Else

' Obtain File object representing uploaded file
Set File = Upload.Files(1)

' Is this a valid image file?
If File.ImageType <> "UNKNOWN" Then

' create instance of AspJpeg object
Set jpeg = Server.CreateObject("Persits.Jpeg")

' open uploaded file
jpeg.Open( File.Path )

' resize image accoring to "scale" option.
' notice that we cannot use Request.Form, so we use Upload.Form

instead.
jpeg.Width = jpeg.OriginalWidth * Upload.Form("scale") / 100
jpeg.Height = jpeg.OriginalHeight * Upload.Form("scale") / 100

SavePath = Server.MapPath("/bilde/") & File.ExtractFileName

' AspJpeg always generates JPEG thumbnails regardless of original

format.
' If the original file was not a JPEG, append .JPG extension.
If UCase(Right(SavePath, 3)) <> "JPG" Then
SavePath = SavePath & ".jpg"
End If

jpeg.Save SavePath

Response.Write "Success! Both the original file and its thumbnail are
saved in the database.<P>"
Response.Write "Copies can be found at <B>c:\upload\" &
File.ExtractFileName & "</B> and <B>" & SavePath & "</B>"

Else
Response.Write "This is not a valid image. <A HREF=""form.asp"">Try
again</A>."
Response.End
End If
End If
%>
</BODY>
</HTML>

"A Ratcliffe" <ar********@archimagic.net> skrev i melding
news:eJ**************@TK2MSFTNGP09.phx.gbl...
BinaryRead and Request.Form/QueryString are mutually exclusive. Once you have used one to read the data, the other is inaccessible.

I found an article on the MSDN library about how to recreate a
pseudo-Request.Form collection but its taken from Active Server

Developer's
Journal, so I'm not sure if its on the web. I'll see if I can find a web article on this, otherwise I'll have a read through the article and give
you
the basics here.

A Ratcliffe
ar********@archimagic.net

"Christopher Brandsdal" <ch***********@c2i.net> wrote in message
news:OG**************@tk2msftngp13.phx.gbl...
> Hi!
>
> I get an error when I run my code
> Is there any other way to get te information from my form?
>
> Heres the error I get and the code beneath.
> Line 120 is market with ''''''''''''Line 120'''''''''''''''''''''
>
>
>

'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''' >

'''''''''''''''''''CODE''''''''''''''''''''''''''' ''''''''''''''''''''''''''
> '''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''
>
> Request object error 'ASP 0207 : 80004005'
> Cannot use Request.Form
>
> /asp/admin/select_image.asp, line 120
>
> Cannot use Request.Form collection after calling BinaryRead.
>
>

'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''
>

'''''''''''''''''''CODE''''''''''''''''''''''''''' ''''''''''''''''''''''''''
> '''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''
>
> if Request.QueryString("action") = "upload" then
> Server.ScriptTimeout = 1200
> Response.Expires = 0
> Response.Buffer = TRUE
> Response.Clear
>
> Dim UploadRequest
> Set UploadRequest = CreateObject("Scripting.Dictionary")
>
> ByteCount = Request.TotalBytes
>
> if ByteCount > Application("MaxFileSize2Upload") then
> Response.Redirect "./select_image.asp?error=05"
> end if
>
>
> RequestBin = Request.BinaryRead(byteCount)
> BuildUploadRequest RequestBin
>
> Dim aux, aux1
> Dim ImageCateg, ContentType, FilePathName, FileName, Value
>
> ImageCateg = Unescape(UploadRequest.Item("inpcatid").Item("Valu e")) 'Image
> Folder
>
> on error resume next
> ContentType = UploadRequest.Item("inpFile").Item("ContentType")
> FILEFLAG = err.number
> on error goto 0
>
> if FILEFLAG = 0 then
> ContentType = UploadRequest.Item("inpFile").Item("ContentType")
> FilePathName = UploadRequest.Item("inpFile").Item("FileName")
> FileName =
> Right(filepathname,Len(filepathname)-InstrRev(filepathname,"\"))
> Value = UploadRequest.Item("inpFile").Item("Value")
> else
> FileName = ""
> end if
>
> Dim objFSO2
> Dim objFSO3
> Dim objUploadFile
> Dim objDelFile1
> Dim OldPath
> '''''''''''''''laster opp bilde'''''''''''''''''''''''''''''
> if FileName<>"" then
> on error resume next
> Set objFSO2 = Server.CreateObject("Scripting.FileSystemObject")
> Set objUploadFile = objFSO2.CreateTextFile(ImageCateg&"\"&FileName) > objUploadFile.Write getString(value)
> objUploadFile.Close
> FILEFLAG = err.number
> on error goto 0
> '''''''''''''''resizer bilde'''''''''''''''''''''''''''''
> ' create instance of AspJpeg object
> Set jpeg = Server.CreateObject("Persits.Jpeg")
>
> ' open uploaded file
> Dim ResizeName
> Dim Ratio
> OldPath = Server.MapPath(Escape(sDir) & Escape(FileName))
> jpeg.Open( OldPath )
> ' resize image accoring to "scale" option.
>
>

'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''
> '''''''''Line
>

120''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''
> '''''''''''''''''''''''''''''''''
> Select Case Request.Form("resize")
>
>

'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''
> '''''''''/Line
>

120/'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''
> ''''''''''''''''''''''''''''''''''
> Case "tn"
> ResizeName = "_miniatyr"
> Ratio = jpeg.OriginalHeight / 100
> jpeg.Width = 100
> jpeg.Height = jpeg.OriginalHeight / Ratio
> Case Else
> ResizeName = "_noko_anna"
> jpeg.Width = jpeg.OriginalWidth * 50 / 100
> jpeg.Height = jpeg.OriginalHeight * 50 / 100
> End Select
> OldPath = Server.MapPath(Escape(sDir)) & "\" & Escape(FileName)
> SavePath = Left(OldPath, InStrRev(OldPath, ".") - 1)
> SavePath = SavePath & ResizeName
> SavePath = SavePath & ".jpg"
> Jpeg.Interpolation = 2
> 'AspJpeg always generates JPEG thumbnails regardless of original
format.
> 'If the original file was not a JPEG, append .JPG extension.
>
> jpeg.Save SavePath
> end if
>
> Set objFSO2 = nothing
> Set objUploadFile = nothing
> Set UploadRequest = nothing
>
>
>



Jul 19 '05 #5

P: n/a
Have you considered a free solution?
It doesn't mention accessing the form variables on the page, but in the
readme.txt file it does.
http://www.asp101.com/articles/jacob/scriptupload.asp
"Christopher Brandsdal" <ch***********@c2i.net> wrote in message
news:u3*************@TK2MSFTNGP10.phx.gbl...
Thanks for helping me!

I think it's possible because AspUpload can do it.

I have AspJpeg installed on my server but NOT AspUpload.
Here is a short AspJpeg script that use something else than Request.Form:

<HTML>
<HEAD>
<TITLE>AspJpeg 1.2 - Upload.asp</TITLE>
</HEAD>
<BODY>

<!-- this script is invoked by form.asp-->
<%
' Create an instance of AspUpload object
Set Upload = Server.CreateObject("Persits.Upload")

' Capture uploaded file. Save returns the number of files uploaded
Count = Upload.Save(Server.MapPath("/"))

If Count = 0 Then
Response.Write "No images selected. <A HREF=""form.asp"">Try again</A>."
Response.End
Else

' Obtain File object representing uploaded file
Set File = Upload.Files(1)

' Is this a valid image file?
If File.ImageType <> "UNKNOWN" Then

' create instance of AspJpeg object
Set jpeg = Server.CreateObject("Persits.Jpeg")

' open uploaded file
jpeg.Open( File.Path )

' resize image accoring to "scale" option.
' notice that we cannot use Request.Form, so we use Upload.Form instead. jpeg.Width = jpeg.OriginalWidth * Upload.Form("scale") / 100
jpeg.Height = jpeg.OriginalHeight * Upload.Form("scale") / 100

SavePath = Server.MapPath("/bilde/") & File.ExtractFileName

' AspJpeg always generates JPEG thumbnails regardless of original format. ' If the original file was not a JPEG, append .JPG extension.
If UCase(Right(SavePath, 3)) <> "JPG" Then
SavePath = SavePath & ".jpg"
End If

jpeg.Save SavePath

Response.Write "Success! Both the original file and its thumbnail are
saved in the database.<P>"
Response.Write "Copies can be found at <B>c:\upload\" &
File.ExtractFileName & "</B> and <B>" & SavePath & "</B>"

Else
Response.Write "This is not a valid image. <A HREF=""form.asp"">Try
again</A>."
Response.End
End If
End If
%>
</BODY>
</HTML>

"A Ratcliffe" <ar********@archimagic.net> skrev i melding
news:eJ**************@TK2MSFTNGP09.phx.gbl...
BinaryRead and Request.Form/QueryString are mutually exclusive. Once you
have used one to read the data, the other is inaccessible.

I found an article on the MSDN library about how to recreate a
pseudo-Request.Form collection but its taken from Active Server

Developer's
Journal, so I'm not sure if its on the web. I'll see if I can find a web
article on this, otherwise I'll have a read through the article and give

you
the basics here.

A Ratcliffe
ar********@archimagic.net

"Christopher Brandsdal" <ch***********@c2i.net> wrote in message
news:OG**************@tk2msftngp13.phx.gbl...
Hi!

I get an error when I run my code
Is there any other way to get te information from my form?

Heres the error I get and the code beneath.
Line 120 is market with ''''''''''''Line 120'''''''''''''''''''''

'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''

'''''''''''''''''''CODE''''''''''''''''''''''''''' ''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''

Request object error 'ASP 0207 : 80004005'
Cannot use Request.Form

/asp/admin/select_image.asp, line 120

Cannot use Request.Form collection after calling BinaryRead.

'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''

'''''''''''''''''''CODE''''''''''''''''''''''''''' ''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''

if Request.QueryString("action") = "upload" then
Server.ScriptTimeout = 1200
Response.Expires = 0
Response.Buffer = TRUE
Response.Clear

Dim UploadRequest
Set UploadRequest = CreateObject("Scripting.Dictionary")

ByteCount = Request.TotalBytes

if ByteCount > Application("MaxFileSize2Upload") then
Response.Redirect "./select_image.asp?error=05"
end if
RequestBin = Request.BinaryRead(byteCount)
BuildUploadRequest RequestBin

Dim aux, aux1
Dim ImageCateg, ContentType, FilePathName, FileName, Value

ImageCateg = Unescape(UploadRequest.Item("inpcatid").Item("Valu e"))

'Image
Folder

on error resume next
ContentType = UploadRequest.Item("inpFile").Item("ContentType")
FILEFLAG = err.number
on error goto 0

if FILEFLAG = 0 then
ContentType = UploadRequest.Item("inpFile").Item("ContentType")
FilePathName = UploadRequest.Item("inpFile").Item("FileName")
FileName =
Right(filepathname,Len(filepathname)-InstrRev(filepathname,"\"))
Value = UploadRequest.Item("inpFile").Item("Value")
else
FileName = ""
end if

Dim objFSO2
Dim objFSO3
Dim objUploadFile
Dim objDelFile1
Dim OldPath
'''''''''''''''laster opp bilde'''''''''''''''''''''''''''''
if FileName<>"" then
on error resume next
Set objFSO2 = Server.CreateObject("Scripting.FileSystemObject")
Set objUploadFile = objFSO2.CreateTextFile(ImageCateg&"\"&FileName) objUploadFile.Write getString(value)
objUploadFile.Close
FILEFLAG = err.number
on error goto 0
'''''''''''''''resizer bilde'''''''''''''''''''''''''''''
' create instance of AspJpeg object
Set jpeg = Server.CreateObject("Persits.Jpeg")

' open uploaded file
Dim ResizeName
Dim Ratio
OldPath = Server.MapPath(Escape(sDir) & Escape(FileName))
jpeg.Open( OldPath )
' resize image accoring to "scale" option.

'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''
'''''''''Line

120''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''
Select Case Request.Form("resize")

'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''
'''''''''/Line

120/'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''
''''''''''''''''''''''''''''''''''
Case "tn"
ResizeName = "_miniatyr"
Ratio = jpeg.OriginalHeight / 100
jpeg.Width = 100
jpeg.Height = jpeg.OriginalHeight / Ratio
Case Else
ResizeName = "_noko_anna"
jpeg.Width = jpeg.OriginalWidth * 50 / 100
jpeg.Height = jpeg.OriginalHeight * 50 / 100
End Select
OldPath = Server.MapPath(Escape(sDir)) & "\" & Escape(FileName)
SavePath = Left(OldPath, InStrRev(OldPath, ".") - 1)
SavePath = SavePath & ResizeName
SavePath = SavePath & ".jpg"
Jpeg.Interpolation = 2
'AspJpeg always generates JPEG thumbnails regardless of original

format.
'If the original file was not a JPEG, append .JPG extension.

jpeg.Save SavePath
end if

Set objFSO2 = nothing
Set objUploadFile = nothing
Set UploadRequest = nothing



Jul 19 '05 #6

P: n/a
Thank you :)
When I read the article I thought.... AHA!
hehe
The problem is solved, and I am happy as a butterfly ;)

"A Ratcliffe" <ar********@archimagic.net> skrev i melding
news:ev**************@TK2MSFTNGP10.phx.gbl...
A quick glance at the web via serach engine found me this article. Its not
perfect in its explanations, but it does cover parsing your own Request.Form data after a BinaryRead.

http://www.juicystudio.com/tutorial/asp/upload.html

HTH,

A Ratcliffe
ar********@archimagic.net

"A Ratcliffe" <ar********@archimagic.net> wrote in message
news:uw**************@TK2MSFTNGP09.phx.gbl...
It's definitely possible (the article I mentioned shows how to do so,

which
is probably how ASPUpload does it).

"Christopher Brandsdal" <ch***********@c2i.net> wrote in message
news:u3*************@TK2MSFTNGP10.phx.gbl...
Thanks for helping me!

I think it's possible because AspUpload can do it.

I have AspJpeg installed on my server but NOT AspUpload.
Here is a short AspJpeg script that use something else than Request.Form:
<HTML>
<HEAD>
<TITLE>AspJpeg 1.2 - Upload.asp</TITLE>
</HEAD>
<BODY>

<!-- this script is invoked by form.asp-->
<%
' Create an instance of AspUpload object
Set Upload = Server.CreateObject("Persits.Upload")

' Capture uploaded file. Save returns the number of files uploaded
Count = Upload.Save(Server.MapPath("/"))

If Count = 0 Then
Response.Write "No images selected. <A HREF=""form.asp"">Try again</A>." Response.End
Else

' Obtain File object representing uploaded file
Set File = Upload.Files(1)

' Is this a valid image file?
If File.ImageType <> "UNKNOWN" Then

' create instance of AspJpeg object
Set jpeg = Server.CreateObject("Persits.Jpeg")

' open uploaded file
jpeg.Open( File.Path )

' resize image accoring to "scale" option.
' notice that we cannot use Request.Form, so we use Upload.Form

instead.
jpeg.Width = jpeg.OriginalWidth * Upload.Form("scale") / 100
jpeg.Height = jpeg.OriginalHeight * Upload.Form("scale") / 100

SavePath = Server.MapPath("/bilde/") & File.ExtractFileName

' AspJpeg always generates JPEG thumbnails regardless of original

format.
' If the original file was not a JPEG, append .JPG extension.
If UCase(Right(SavePath, 3)) <> "JPG" Then
SavePath = SavePath & ".jpg"
End If

jpeg.Save SavePath

Response.Write "Success! Both the original file and its thumbnail are saved in the database.<P>"
Response.Write "Copies can be found at <B>c:\upload\" &
File.ExtractFileName & "</B> and <B>" & SavePath & "</B>"

Else
Response.Write "This is not a valid image. <A HREF=""form.asp"">Try
again</A>."
Response.End
End If
End If
%>
</BODY>
</HTML>

"A Ratcliffe" <ar********@archimagic.net> skrev i melding
news:eJ**************@TK2MSFTNGP09.phx.gbl...
> BinaryRead and Request.Form/QueryString are mutually exclusive. Once you > have used one to read the data, the other is inaccessible.
>
> I found an article on the MSDN library about how to recreate a
> pseudo-Request.Form collection but its taken from Active Server
Developer's
> Journal, so I'm not sure if its on the web. I'll see if I can find a web > article on this, otherwise I'll have a read through the article and give you
> the basics here.
>
> A Ratcliffe
> ar********@archimagic.net
>
> "Christopher Brandsdal" <ch***********@c2i.net> wrote in message
> news:OG**************@tk2msftngp13.phx.gbl...
> > Hi!
> >
> > I get an error when I run my code
> > Is there any other way to get te information from my form?
> >
> > Heres the error I get and the code beneath.
> > Line 120 is market with ''''''''''''Line 120'''''''''''''''''''''
> >
> >
> >
>

'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''
> >
>

'''''''''''''''''''CODE''''''''''''''''''''''''''' ''''''''''''''''''''''''''
> > '''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''
> >
> > Request object error 'ASP 0207 : 80004005'
> > Cannot use Request.Form
> >
> > /asp/admin/select_image.asp, line 120
> >
> > Cannot use Request.Form collection after calling BinaryRead.
> >
> >
>

'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''
> >
>

'''''''''''''''''''CODE''''''''''''''''''''''''''' ''''''''''''''''''''''''''
> > '''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''
> >
> > if Request.QueryString("action") = "upload" then
> > Server.ScriptTimeout = 1200
> > Response.Expires = 0
> > Response.Buffer = TRUE
> > Response.Clear
> >
> > Dim UploadRequest
> > Set UploadRequest = CreateObject("Scripting.Dictionary")
> >
> > ByteCount = Request.TotalBytes
> >
> > if ByteCount > Application("MaxFileSize2Upload") then
> > Response.Redirect "./select_image.asp?error=05"
> > end if
> >
> >
> > RequestBin = Request.BinaryRead(byteCount)
> > BuildUploadRequest RequestBin
> >
> > Dim aux, aux1
> > Dim ImageCateg, ContentType, FilePathName, FileName, Value
> >
> > ImageCateg = Unescape(UploadRequest.Item("inpcatid").Item("Valu e")) > 'Image
> > Folder
> >
> > on error resume next
> > ContentType = UploadRequest.Item("inpFile").Item("ContentType")
> > FILEFLAG = err.number
> > on error goto 0
> >
> > if FILEFLAG = 0 then
> > ContentType = UploadRequest.Item("inpFile").Item("ContentType") > > FilePathName = UploadRequest.Item("inpFile").Item("FileName")
> > FileName =
> > Right(filepathname,Len(filepathname)-InstrRev(filepathname,"\"))
> > Value = UploadRequest.Item("inpFile").Item("Value")
> > else
> > FileName = ""
> > end if
> >
> > Dim objFSO2
> > Dim objFSO3
> > Dim objUploadFile
> > Dim objDelFile1
> > Dim OldPath
> > '''''''''''''''laster opp bilde'''''''''''''''''''''''''''''
> > if FileName<>"" then
> > on error resume next
> > Set objFSO2 = Server.CreateObject("Scripting.FileSystemObject") > > Set objUploadFile =

objFSO2.CreateTextFile(ImageCateg&"\"&FileName)
> > objUploadFile.Write getString(value)
> > objUploadFile.Close
> > FILEFLAG = err.number
> > on error goto 0
> > '''''''''''''''resizer bilde'''''''''''''''''''''''''''''
> > ' create instance of AspJpeg object
> > Set jpeg = Server.CreateObject("Persits.Jpeg")
> >
> > ' open uploaded file
> > Dim ResizeName
> > Dim Ratio
> > OldPath = Server.MapPath(Escape(sDir) & Escape(FileName))
> > jpeg.Open( OldPath )
> > ' resize image accoring to "scale" option.
> >
> >
>

'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''
> > '''''''''Line
> >
>

120''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''
> > '''''''''''''''''''''''''''''''''
> > Select Case Request.Form("resize")
> >
> >
>

'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''
> > '''''''''/Line
> >
>

120/'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''
> > ''''''''''''''''''''''''''''''''''
> > Case "tn"
> > ResizeName = "_miniatyr"
> > Ratio = jpeg.OriginalHeight / 100
> > jpeg.Width = 100
> > jpeg.Height = jpeg.OriginalHeight / Ratio
> > Case Else
> > ResizeName = "_noko_anna"
> > jpeg.Width = jpeg.OriginalWidth * 50 / 100
> > jpeg.Height = jpeg.OriginalHeight * 50 / 100
> > End Select
> > OldPath = Server.MapPath(Escape(sDir)) & "\" & Escape(FileName)
> > SavePath = Left(OldPath, InStrRev(OldPath, ".") - 1)
> > SavePath = SavePath & ResizeName
> > SavePath = SavePath & ".jpg"
> > Jpeg.Interpolation = 2
> > 'AspJpeg always generates JPEG thumbnails regardless of original > format.
> > 'If the original file was not a JPEG, append .JPG extension.
> >
> > jpeg.Save SavePath
> > end if
> >
> > Set objFSO2 = nothing
> > Set objUploadFile = nothing
> > Set UploadRequest = nothing
> >
> >
> >
>
>



Jul 19 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.