jrthor2
07-22-2003, 11:16 AM
I have a script that uploads files with no problem right now. I am trying to modify it to look for a category and put the files in a directory based on the category they choose. Below is my code, but I get the error:
Request object error 'ASP 0207 : 80004005'
Cannot use Request.Form
/admin/upload/upload.asp, line 49
Cannot use Request.Form collection after calling BinaryRead.
Code:
<%@ Language=VBScript %>
<%
option explicit
Response.Expires = -1
Server.ScriptTimeout = 9800
%>
<%
'If the session variable is False or does not exsist then redirect the user to the login user page
If (Session("level")) <= 1 then
'Redirect to login user page
Response.Redirect"/admin/login.asp"
'Else
'name = Request.Querystring("name")
End If
'Response.Write ("Level " & Session("level"))
%>
<!-- #include file="inc/upload.asp" -->
<%
Dim mesg, Uploader, File, baseDir, extDir, txtExt, bodytag, Mailer, txtFileList, cat
Set Uploader = New FileUploader
baseDir = "/admin/upload"
Uploader.Upload()
If Uploader.Form("submit") = "Upload" then
If Uploader.Files.Count = 0 Then
mesg = "File Not Uploaded"
Else
For Each File In Uploader.Files.Items
txtExt = LCase(Right(File.Filename, 3))
If txtExt = "jpg" Or _
txtExt = "bmp" Or _
txtExt = "tif" Or _
txtExt = "eps" Or _
txtExt = "png" Or _
txtExt = "psd" Or _
txtExt = "gif" Then
extDir = baseDir & "/images"
txtFileList = txtFileList & "images/" & File.FileName & "," & Chr(13)
Elseif txtExt = "wpd" Then
extDir = basedir & "/wordperfect"
txtFileList = txtFileList & "wordperfect/" & File.FileName & "," & Chr(13)
Elseif txtExt = "pdf" AND Request.Form("cat") = "Council Minutes" Then
extDir = "/newsletter"
txtFileList = txtFileList & "/Council_Minutes/" & File.FileName & "," & Chr(13)
Elseif txtExt = "pdf" AND Request.Form("cat") = "Newsletter" Then
extDir = "/newsletter"
txtFileList = txtFileList & "/Newsletter/" & File.FileName & "," & Chr(13)
Else
extDir = baseDir & "/files"
txtFileList = txtFileList & "files/" & File.FileName & "," & Chr(13)
End If
File.SaveToDisk Server.MapPath(extDir)
Next
mesg = "File(s) uploaded successfully"
Set Mailer = Server.CreateObject("SMTPsvg.Mailer")
Mailer.FromName = "Zion Upload Files"
Mailer.FromAddress = "webmaster@zluth.org"
Mailer.RemoteHost = "localhost"
Mailer.AddRecipient "Jason Roscoe", "jroscoe10@comcast.net"
Mailer.Subject = "Files have been uploaded to Zion's website"
Mailer.BodyText = "The following files have been uploaded to the upload directory on Zion's website:" & Chr(13) & Chr(13) & txtFileList
if Mailer.SendMail then
else
Response.Write "Mail send failure1. Error was " & Mailer.Response
end if
End If
End If
%>
<HTML>
<HEAD>
<TITLE>Zion Evangelical Lutheran Church - Upload</TITLE>
<style>
BODY {background-color: white;font-family:arial; font-size:12}
</style>
<!--#include virtual="/inc/head_include.asp"-->
</HEAD>
<BODY <% Response.Write(bodytag) %>>
<table width="100%" border="0" cellspacing="0" cellpadding="2">
<tr>
<td rowspan="2" valign="top">
<!--#include virtual="/inc/Menu.asp"-->
</td>
<td width="100%" valign="top">
<!--#include virtual="/inc/layout_top.asp"-->
<!--#include virtual="/inc/admin_top.asp"-->
</td>
</tr>
<tr>
<td height="450" valign="top">
<div align="center">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="5%" valign="top"><img src="images/ftp2.gif" width="130" height="119" hspace="0" vspace="0" border="0"></td>
<td width="95%"><div align="center">
<p align="left"><font class="fontsize5"><u>Upload
Files</u></font></p>
</div>
<span class="color: red; font-weight: 600;"><%=mesg%></span><br>
<form action="upload.asp" method=post enctype="multipart/form-data">
<p>
<input type=file name="file1" size=40 class="button">
<br>
<input type=file name="file2" size=40 class="button">
</p>
<p>
<input type="radio" name="cat" value="Council Minutes">
Council
Minutes
<input type="radio" name="cat" value="Newsletter">
Newsletter
<br>
<input type=submit id="submit" name="submit" value="Upload" class="button">
</p>
</form></td>
</tr>
<tr>
<td valign="top"> </td>
<td><a href="view_files.asp">View
Files
</a></td>
</tr>
</table>
</div>
</td>
</tr>
<tr>
<td colspan="2">
<!--#include virtual="/inc/layout_bottom.htm"-->
</td>
</tr>
</table>
</BODY>
</HTML>
Request object error 'ASP 0207 : 80004005'
Cannot use Request.Form
/admin/upload/upload.asp, line 49
Cannot use Request.Form collection after calling BinaryRead.
Code:
<%@ Language=VBScript %>
<%
option explicit
Response.Expires = -1
Server.ScriptTimeout = 9800
%>
<%
'If the session variable is False or does not exsist then redirect the user to the login user page
If (Session("level")) <= 1 then
'Redirect to login user page
Response.Redirect"/admin/login.asp"
'Else
'name = Request.Querystring("name")
End If
'Response.Write ("Level " & Session("level"))
%>
<!-- #include file="inc/upload.asp" -->
<%
Dim mesg, Uploader, File, baseDir, extDir, txtExt, bodytag, Mailer, txtFileList, cat
Set Uploader = New FileUploader
baseDir = "/admin/upload"
Uploader.Upload()
If Uploader.Form("submit") = "Upload" then
If Uploader.Files.Count = 0 Then
mesg = "File Not Uploaded"
Else
For Each File In Uploader.Files.Items
txtExt = LCase(Right(File.Filename, 3))
If txtExt = "jpg" Or _
txtExt = "bmp" Or _
txtExt = "tif" Or _
txtExt = "eps" Or _
txtExt = "png" Or _
txtExt = "psd" Or _
txtExt = "gif" Then
extDir = baseDir & "/images"
txtFileList = txtFileList & "images/" & File.FileName & "," & Chr(13)
Elseif txtExt = "wpd" Then
extDir = basedir & "/wordperfect"
txtFileList = txtFileList & "wordperfect/" & File.FileName & "," & Chr(13)
Elseif txtExt = "pdf" AND Request.Form("cat") = "Council Minutes" Then
extDir = "/newsletter"
txtFileList = txtFileList & "/Council_Minutes/" & File.FileName & "," & Chr(13)
Elseif txtExt = "pdf" AND Request.Form("cat") = "Newsletter" Then
extDir = "/newsletter"
txtFileList = txtFileList & "/Newsletter/" & File.FileName & "," & Chr(13)
Else
extDir = baseDir & "/files"
txtFileList = txtFileList & "files/" & File.FileName & "," & Chr(13)
End If
File.SaveToDisk Server.MapPath(extDir)
Next
mesg = "File(s) uploaded successfully"
Set Mailer = Server.CreateObject("SMTPsvg.Mailer")
Mailer.FromName = "Zion Upload Files"
Mailer.FromAddress = "webmaster@zluth.org"
Mailer.RemoteHost = "localhost"
Mailer.AddRecipient "Jason Roscoe", "jroscoe10@comcast.net"
Mailer.Subject = "Files have been uploaded to Zion's website"
Mailer.BodyText = "The following files have been uploaded to the upload directory on Zion's website:" & Chr(13) & Chr(13) & txtFileList
if Mailer.SendMail then
else
Response.Write "Mail send failure1. Error was " & Mailer.Response
end if
End If
End If
%>
<HTML>
<HEAD>
<TITLE>Zion Evangelical Lutheran Church - Upload</TITLE>
<style>
BODY {background-color: white;font-family:arial; font-size:12}
</style>
<!--#include virtual="/inc/head_include.asp"-->
</HEAD>
<BODY <% Response.Write(bodytag) %>>
<table width="100%" border="0" cellspacing="0" cellpadding="2">
<tr>
<td rowspan="2" valign="top">
<!--#include virtual="/inc/Menu.asp"-->
</td>
<td width="100%" valign="top">
<!--#include virtual="/inc/layout_top.asp"-->
<!--#include virtual="/inc/admin_top.asp"-->
</td>
</tr>
<tr>
<td height="450" valign="top">
<div align="center">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="5%" valign="top"><img src="images/ftp2.gif" width="130" height="119" hspace="0" vspace="0" border="0"></td>
<td width="95%"><div align="center">
<p align="left"><font class="fontsize5"><u>Upload
Files</u></font></p>
</div>
<span class="color: red; font-weight: 600;"><%=mesg%></span><br>
<form action="upload.asp" method=post enctype="multipart/form-data">
<p>
<input type=file name="file1" size=40 class="button">
<br>
<input type=file name="file2" size=40 class="button">
</p>
<p>
<input type="radio" name="cat" value="Council Minutes">
Council
Minutes
<input type="radio" name="cat" value="Newsletter">
Newsletter
<br>
<input type=submit id="submit" name="submit" value="Upload" class="button">
</p>
</form></td>
</tr>
<tr>
<td valign="top"> </td>
<td><a href="view_files.asp">View
Files
</a></td>
</tr>
</table>
</div>
</td>
</tr>
<tr>
<td colspan="2">
<!--#include virtual="/inc/layout_bottom.htm"-->
</td>
</tr>
</table>
</BODY>
</HTML>