Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

upload to a dir and update a db at the same time?

Status
Not open for further replies.

help120

Technical User
Apr 15, 2001
198
0
0
US
I've 3 pages.. upload1.asp is a form to take info that will be used to upload a file to a dir and the other fields will be used to update a db. I then have a page "submit.asp" that process the info. I get this error when I try to submit the info...

Request object error 'ASP 0207 : 80004005'

Cannot use Request.Form

/v4/gy/submit.asp, line 43

Cannot use Request.Form collection after calling BinaryRead.

can some one please help me out?

'##############################UPLOAD1.asp###
<form enctype=&quot;multipart/form-data&quot; method=&quot;POST&quot; action=&quot;submit.asp&quot;>

<TABLE BORDER=0>
<tr><td><b>Enter your fullname:</b><br><INPUT TYPE=TEXT SIZE=40 NAME=&quot;FULLNAME&quot;></td></tr>
<tr><td><b>Select a file to upload:</b><br><INPUT TYPE=FILE SIZE=50 NAME=&quot;FILE1&quot;></td></tr>

</TABLE>
<input type=&quot;hidden&quot; name=&quot;date&quot; size=&quot;20&quot; value=&quot;<%response.write(date())%>-<%response.write(time())%>&quot;>
larg_img<input type=&quot;text&quot; name=&quot;larg_img&quot; size=&quot;20&quot;><br>
small_img<input type=&quot;text&quot; name=&quot;small_img&quot; size=&quot;20&quot;><br>
author<input type=&quot;text&quot; name=&quot;author&quot; size=&quot;20&quot;><br>
email<input type=&quot;text&quot; name=&quot;email&quot; size=&quot;20&quot;><br>
category<input type=&quot;text&quot; name=&quot;cat&quot; size=&quot;20&quot;><br>


<input type=&quot;submit&quot; value=&quot;Submit&quot; name=&quot;B1&quot;><input type=&quot;reset&quot; value=&quot;Reset&quot; name=&quot;B2&quot;></p>
</form>
'################END UPLOAD1.asp###############

'###############SUBMIT.asp#####################
<%@ Language=VBScript %>
<% Option Explicit %>
<!--#INCLUDE VIRTUAL=&quot;adovbs.inc&quot; -->
<!-- #include file=&quot;upload.asp&quot; -->
<%
' Create the FileUploader
Dim Uploader, File
Set Uploader = New FileUploader

' This starts the upload process
Uploader.Upload()

Response.Write &quot;<b>Thank you for your upload &quot; & Uploader.Form(&quot;fullname&quot;) & &quot;</b><br>&quot;

' Check if any files were uploaded
If Uploader.Files.Count = 0 Then
Response.Write &quot;File(s) not uploaded.&quot;
Else
' Loop through the uploaded files
For Each File In Uploader.Files.Items

' Check where the user wants to save the file
'If Uploader.Form(&quot;saveto&quot;) = &quot;disk&quot; Then

' Save the file
File.SaveToDisk &quot;c:\inetpub\finalphase\
' Output the file details to the browser
Response.Write &quot;File Uploaded: &quot; & File.FileName & &quot;<br>&quot;
Response.Write &quot;Size: &quot; & File.FileSize & &quot; bytes<br>&quot;
Response.Write &quot;Type: &quot; & File.ContentType & &quot;<br><br>&quot;
Next
End If

%>
<%
Set MyConn = Server.CreateObject(&quot;ADODB.Connection&quot;)
MyConn.ConnectionString = &quot;DBQ=C:\inetpub\finalphase\ Access Driver (*.mdb)}&quot;
MyConn.Open
dim MyConn, sql, date, larg_img, small_img, author, email, cat %>

<%
date = Request.Form(&quot;date&quot;)
larg_img = Request.Form(&quot;larg_img&quot;)
small_img= Request.Form(&quot;small_img&quot;)
author= Request.Form(&quot;author&quot;)
email= Request.Form(&quot;email&quot;)
cat= Request.Form(&quot;cat&quot;)

'build up first INSERT
sql = &quot;INSERT INTO gallery (larg_img,small_img,author,email,cat) values(&quot;
sql = sql & &quot;'&quot; & larg_img & &quot;',&quot;
sql = sql & &quot;'&quot; & small_img & &quot;',&quot;
sql = sql & &quot;'&quot; & author & &quot;',&quot;
sql = sql & &quot;'&quot; & email & &quot;',&quot;
sql = sql & &quot;'&quot; & cat & &quot;')&quot;

'execute first statement
myConn.execute sql

set myConn = nothing
%>
'######################END SUBMIT############
 
Hi,

In your code above there is a conflicting code: When you use enctype=&quot;multipart/form-data&quot; in your <form> tag, you cant simply access other data by request.form. In my project which is similar of what you did, we bought a component for that-ASPupload Component for us to upload the files and save it in our server, other data we receive it using this code Upload.form(&quot;theformfield&quot;).Using enctype=&quot;multipart/form-data&quot; the data you have entered is pass differently so you can't access it by request.form or by any means other than Upload.form.

Hope this Helps!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top