Ask a Question related to ASP Database, Design and Development.
-
Fredrik/Sweden #1
request.form & binaryRead - error !
hi everybody !
now i have finally managed to build a upload/download file-part in my
application, and it's working just fine, except for one detail.
i use a simple form where the user can choose a file to upload. a also
have a checkbox that should be checked if the file is a 'released'
version, and unchecked if it is a preview/work in progress. i want the
value of this checkbox to be passed to the Insert file and inserted
into the database.
I get the message: Cannot call BinaryRead after using Request.Form
collection.
I've read about it and realised that i can't use Request.Form when i
use binary read/write.
i just want each file in the database to have a true/false status in
the 'Released'-field in the database. now every file is 'false' since
i can't pass the value of the checkbox.
is there an easy way of working around this ? i've seen a few things
on the web but haven't found anything that works for me yet.
code included below:
--------------------------------------------------------------------------
<!-- insert.htm -->
<html>
<head>
<title>Inserts files into Database</title>
<style>
body, input { font-family:verdana,arial; font-size:10pt; }
</style>
</head>
<body>
<p align="center">
<b>Inserting files into Database</b><br>
<a href="show.asp">To see uploaded files click here</a>
</p>
<table border="0" align="center" cellpadding = "10">
<tr>
<form method="POST" enctype="multipart/form-data"
action="Insert.asp">
<td><p>File :</p></td>
<td><input type="file" name="file" size="40"></td>
</tr><tr>
<td><p>Released :</p></td>
<td><input type="checkbox" name="check"></td>
</tr><tr>
<td></td>
<td></td>
</tr><tr>
<td> </td>
<td><input type="submit" value="Submit"></td></tr>
</form>
</tr>
</table>
</body>
</html>
------------------------------------------------------------------------------
<!--#Include File="Connect.asp" -->
<% ' Insert.asp %>
<!--#include file="Loader.asp"-->
<%
Response.Buffer = True
Dim checked
'checked = Request.Form("check") 'NOT POSSIBLE HERE
' load object
Dim load
Set load = new Loader
' calling initialize method
load.initialize
' File binary data
Dim fileData
fileData = load.getFileData("file")
' File name
Dim fileName
fileName = LCase(load.getFileName("file"))
' File path
Dim filePath
filePath = load.getFilePath("file")
' File path complete
Dim filePathComplete
filePathComplete = load.getFilePathComplete("file")
' File size
Dim fileSize
fileSize = load.getFileSize("file")
' File size translated
Dim fileSizeTranslated
fileSizeTranslated = load.getFileSizeTranslated("file")
' Content Type
Dim contentType
contentType = load.getContentType("file")
' No. of Form elements
Dim countElements
countElements = load.Count
' destroying load object
Set load = Nothing
%>
<html>
<head>
<title>Inserts files into Database</title>
<style>
body, input, td { font-family:verdana,arial; font-size:10pt; }
</style>
</head>
<body>
<p align="center">
<b>Inserting Binary Data into Database</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><%= filePathComplete %></td>
</tr><tr>
<td>File Size</td><td><%= fileSize %></td>
</tr><tr>
<td>File Size Translated</td><td><%= fileSizeTranslated %></td>
</tr><tr>
<td>Content Type</td><td><%= contentType %></td>
</tr><tr>
<td>No. of Form Elements</td><td><%= countElements %></td>
</tr>
</table><br><br>
<p style="padding-left:220;">
<%= fileName %> data received ...<br>
<%
' Checking to make sure if file was uploaded
If fileSize > 0 Then
' Recordset object
Dim rs
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open "Files", Con, 2, 2
' Adding data
rs.AddNew
rs("FileName") = fileName
rs("File Size") = fileSize
rs("File Data").AppendChunk fileData
rs("Content Type") = contentType
rs("Project") = Session("Project")
rs("Author") = Session("Author")
rs("UDate") = NOW()
'rs("Released") = checked 'HOW DO I SOLVE THIS ???
rs.Update
rs.Close
Set rs = Nothing
Response.Write "<font color=""green"">File was successfully
uploaded..."
Response.Write "</font>"
Else
Response.Write "<font color=""brown"">No file was selected for
uploading"
Response.Write "...</font>"
End If
If Err.number <> 0 Then
Response.Write "<br><font color=""red"">Something went wrong..."
Response.Write "</font>"
End If
%>
</p>
<br>
<table border="0" align="center" cellpadding = "10">
<tr>
<form method="POST" enctype="multipart/form-data"
action="Insert.asp">
<td><p>File :</p></td>
<td><input type="file" name="file" size="40"></td>
</tr><tr>
<td><p>Released :</p></td>
<td><input type="checkbox" name="check"></td>
</tr><tr>
<td></td>
<td></td>
</tr><tr>
<td> </td>
<td><input type="submit" value="Submit"></td></tr>
</form>
</tr>
</table>
</body>
</html>
--------------------------------------------------------------------------
THANKS !!!
Fredrik/Sweden Guest
-
Request.BinaryRead
Hi, I am migrating my ASP application from IIS5 environment to IIS6. My problem is, i get an error Request object error 'ASP 0104 : 80004005'... -
Cannot use the generic Request collection after calling BinaryRead
hI, Task is to save the contents of an image ie .jpg/.gif file to the SQL Server. To accomplish this I open the file and save the contents using... -
Error Request.BinaryRead in IIS 5.0 on Windows Nt 2000 SP3
Sometimes when loading binary files with Request.BinaryRead IIS on the log gives me the following Error (I have analyzed IIS Log with Web Trend... -
Error on Request.BinaryRead in IIS 6.0 (Win 2003)
I have a VBscript that I use to upload files onto the server. The script works fine on IIS 5.0 but on IIS 6.0 on Windows 2003 I get an error when... -
Unspecified Error (80004005) executing Request.Form()
There is a limit to the amount of data you can post through a form. For a file of that size you probably need to treat it as an upload. ... -
Atrax #2
Re: request.form & binaryRead - error !
that's right, you can't use BinaryRead and Request.Form in the same
instance. well known fact.
do you have an upload component available to you? I assume not if you've
had to do this in script... but they're a LOT less hassle.
________________________________________
Atrax. MVP, IIS
[url]http://rtfm.atrax.co.uk/[/url]
newsflash : Atrax.Richedit 1.0 now released.
[url]http://rtfm.atrax.co.uk/infinitemonkeys/components/Atrax.RichEdit/[/url]
*** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
Don't just participate in USENET...get rewarded for it!
Atrax Guest
-
Fredrik Holm #3
Re: request.form & binaryRead - error !
hi again !
well, i know there are lots of different components out there for free.
but i wanted to do as much as possible by myself, and i got this working
fine except for this detail.
i just want the value of the checkbox to be passed to the the next page,
that's all. isn't there some way of working around this ? can it be done
in asp ? can i use javascript or something to make the variable known
globaly ?
Fredrik - Sweden
*** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
Don't just participate in USENET...get rewarded for it!
Fredrik Holm Guest



Reply With Quote

