Im New To ASP And Am Terible At It. I Made This From Random Bits Of Free Code I Found. The Problem: When i remove The Section With The *******'s, Everything Works Fine And Uploads The Pictures. Im Trying To Write To A Text file What Are In The TextFields(Text Boxes). I Keep Getting This Error:
Error Type:
Request object, ASP 0207 (0x80004005)
Cannot use Request.Form collection after calling BinaryRead.
/upload/uploadpic.asp, line 39
Any Help Is Appreciated
Thanks In Advance
-Brian
<%
Const imageExts = ".gif,.jpg,.png,.jpeg,.bmp,.ico"
Const MaxFileSize = &H180000
Server.ScriptTimeout = 2000
Dim DestinationPath
DestinationPath = ("C:\Stored Files\uploadedfiles\")
Dim Form: Set Form = New ASPForm %><!--#INCLUDE FILE="_upload.asp"--><%
Server.ScriptTimeout = 1000
Form.SizeLimit = &HA00000
if len(Request.QueryString("UploadID"))>0 Then
Form.UploadID = Request.QueryString("UploadID")'{/b}
end if
Const fsCompletted = 0
If Form.State = fsCompletted Then
if Form.State = 0 then
response.write "<br><b>Upload result: Form was accepted.</b>"
response.write "<br>Number of file fields:" & Form.Files.Count
response.write "<br>Request total bytes:" & Request.TotalBytes
Dim Field
For each Field in Form.Files.Items
response.write "<br>File:" & Field.FileName & ", size :" & (Field.Length \ 1024 +1) & "kB"
if instr(1, imageExts & ",", Field.FileExt & ",", 1)>0 Then
if Field.Length<=MaxFileSize Then
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set FileObject = Server.CreateObject("Scripting.FileSystemObject")
LogFile = ("C:\Stored Files\uploadedfiles\Log.txt.txt")
Set OutputStream = FileObject.OpenTextFile (LogFile, ForAppending, True)
OutputStream.WriteLine "Date: " + CStr(Now())
OutputStream.WriteLine "IP: " + Request.ServerVariables ("LOCAL_ADDR")
**********OutputStream.WriteLine "Year: " + request.form("CarYear")
**********OutputStream.WriteLine "Model: " + request.form("CarModel")
**********OutputStream.WriteLine "Your Email Address: " + request.form("Email")
OutputStream.WriteLine " "
OutputStream.Close
Set OutputStream = Nothing
Set FileObject = Nothing
Field.Save DestinationPath
response.write"<Font Color=green> <b>was stored to a disk.</b></font>"
else
response.write "<Font Color=red> <b>exceeds file limit</b> (" & (MaxFileSize \ 1024 +1) & "kB).</font>"
end if
else
response.write "<Font Color=red><b> is not an image type </b> (" & imageExts & ").</font>"
end if
Next
End If
ElseIf Form.State > 10 then
Const fsSizeLimit = &HD
Select case Form.State
case fsSizeLimit: response.write "<br><Font Color=red>Source form size (" & Form.TotalBytes & "B) exceeds form limit (" & Form.SizeLimit & "B)</Font><br>"
case else response.write "<br><Font Color=red>Some form error.</Font><br>"
end Select
End If'Form.State = 0 then
Dim UploadID, PostURL
UploadID = Form.NewUploadID
PostURL = Request.ServerVariables("SCRIPT_NAME") & "?UploadID=" & UploadID'{/b}
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<TITLE>ASP huge file upload - file size limit with progress bar.</TITLE>
<STYLE TYPE="text/css">
<!--TD {font-family:Arial,Helvetica,sans-serif }TH {font-family:Arial,Helvetica,sans-serif }TABLE {font-size:10pt;font-family:Arial,Helvetica,sans-serif }.style5 {
color: #000066;
font-family: "Times New Roman", Times, serif;
font-size: 12;
}
.style6 {
font-size: 12px;
color: #333333;
}
.style7 {
font-size: 14px;
color: #000099;
}
.style8 {color: #FFFFFF}
--></STYLE>
</HEAD>
<BODY BGColor=white>
<Div style=width:600>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
</TABLE>
<TABLE cellSpacing=2 cellPadding=1 width="100%" bgColor=white border=0>
<TR>
<TD colSpan=2>
<P class="style5 style7"> For Your Picture To Be Used It <strong>MUST</strong>: <br>
..........1) Be Less Than 1.5mb (1,537kb). <br>
..........2) Be In A >>>.gif,.jpg,.png,.jpeg,.bmp,.ico<< < Format. <br>
..........3) Include Your Fist Name, The Year, And The Model. <br>
..........4) Be Good Quality <br>
..........5) Be A Chevy</P></TD>
</TR>
</TABLE>
<hr size="3">
<form name="file_upload" method="POST" ENCTYPE="multipart/form-data" OnSubmit="return ProgressBar();" Action="<%=PostURL%>">
<Div ID=files>
File 1 : <input type="file" name="File1" onchange=preview(this) onfocus=preview(this)>
</Div>
<input type="Button" name="Submit" value="Add A File" OnClick=return(Expand())>
<span class="style6"><<<Click "Add A File" To Upload More Than One Picture (Maximum Of 5)<<<<br>
</span><br>
<table width="200" border="0">
<tr>
<td>Year:</td>
<td><input type="text" name="CarYear" size="10"></td>
</tr>
<tr>
<td>Model:</td>
<td><input name="CarModel" type="text" id="CarModel" size="30"></td>
</tr>
<tr>
<td>Email:</td>
<td><input name="Email" type="text" id="Email" size="30"></td>
</tr>
</table>
<br>
<input Name=SubmitButton Value="**Submit **" Type=Submit>
<br>
</Form>
<SCRIPT>
function ProgressBar(){
var ProgressURL
ProgressURL = 'progress-limit.asp?UploadID=<%=UploadID%>'
var v = window.open(ProgressURL,'_blank','toolbar=no,locat ion=no,directories=no,status=no,menubar=no,scrollb ars=no,resizable=yes,width=350,height=200')
return true;
}
</SCRIPT>
<Script>
var nfiles = 1;
function Expand(){
if(nfiles < 5){
nfiles++
var adh = '<BR> File '+nfiles+' : <input type="file" name="File'+nfiles+'"onchange=preview(this) onfocus=preview(this)>';
files.insertAdjacentHTML('BeforeEnd',adh);
return false;}
}
</Script>
<tr><td><Div ID=ImageName>Image preview :</Div></td><td>
<img src=http://www.chevy-pics.doesntexist.com/pics/blank.jpg height="75" border=0 ID=ipreview>
<br></td>
</tr>
<Script>
function isImage(file){
var ext = file.substr(file.lastIndexOf('.')).toLowerCase()
return '<%=imageExts%>,'.indexOf(ext+',') >= 0
};
var lastfieldname = ''
function preview(i) {
var file = i.value
if (file.length<=0) return;
var ipreview = document.all('ipreview')
if (isImage(file)) {
ipreview.src = 'file://' + file
ImageName.innerHTML = 'Image preview<br>(' + i.name + ')'
} else {
ipreview.src = 'res://shdoclc.dll/warning.gif'
};
lastfieldname = i.name
}
window.onerror = donotmsgboxes;
function donotmsgboxes(msg,url,line)
{
return true
}
</Script>
<br>
<hr color=silver size=3>
<CENTER>
</CENTER>
</Div>
</BODY></HTML>