If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Please Help

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-21-04, 19:30
ynk1121 ynk1121 is offline
Registered User
 
Join Date: Jan 2004
Location: NY
Posts: 5
Unhappy Please Help

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">&nbsp;For Your Picture To Be Used It <strong>MUST</strong>: <br>
..........1) Be Less Than 1.5mb (1,537kb). <br>
..........2) Be In A &gt;&gt;&gt;.gif,.jpg,.png,.jpeg,.bmp,.ico&lt;&lt; &lt; 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">&lt;&lt;&lt;Click &quot;Add A File&quot; To Upload More Than One Picture (Maximum Of 5)&lt;&lt;&lt;<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>
Reply With Quote
  #2 (permalink)  
Old 01-22-04, 08:39
yoja7 yoja7 is offline
Registered User
 
Join Date: Jan 2004
Location: India
Posts: 31
Hi

I was too hasty to read all ur code, but i think u want ot upload files and paste some data in Text format.

what i would suggest to use an free asp upload component

http://www.freeaspupload.net/

i am using it...it wrks fine :-)

if u go fwd to use it, u can acces Your text fields as

UpLoad.Form("YourTextField")

tats all

bye
keep posted
Attached Files
File Type: zip freeaspupload.zip (4.7 KB, 53 views)
__________________
Do not walk behind me, for I may not lead.
Do not walk ahead of me, for I may not follow.
Do not walk beside me, either.
Just leave me alone.

Yogesh Jangam
http://yogeshjangam.*************
Reply With Quote
  #3 (permalink)  
Old 01-22-04, 23:32
gyuan gyuan is offline
Registered User
 
Join Date: Dec 2003
Posts: 454
Post the code on line 39.
Reply With Quote
  #4 (permalink)  
Old 01-23-04, 04:13
ynk1121 ynk1121 is offline
Registered User
 
Join Date: Jan 2004
Location: NY
Posts: 5
Re: Please Help

the code uploads a picture just fine but i want to also save whats in the text fields to a txt or access file. i tryed using request.form but thats giving me the error.
Line 39 is

OutputStream.WriteLine "Year: " + request.form("CarYear")

i removed the pieces of code at were giving me the error. i included all the files as an attachment. i figured it would be easier to fix if you have the files.
Attached Files
File Type: zip upload.zip (12.6 KB, 34 views)

Last edited by ynk1121; 01-23-04 at 05:42.
Reply With Quote
  #5 (permalink)  
Old 01-23-04, 07:22
rhs98 rhs98 is offline
Super Moderator
 
Join Date: Feb 2002
Location: Hampshire, UK
Posts: 441
Use & not + to concatenate things with strings, + is maths stuff and can cause problems. Not sure if thats what is causing your problem, try it and see.
Reply With Quote
  #6 (permalink)  
Old 01-23-04, 18:39
ynk1121 ynk1121 is offline
Registered User
 
Join Date: Jan 2004
Location: NY
Posts: 5
Unhappy

nope. i replaced the +'s with &'s and get the same error
Reply With Quote
  #7 (permalink)  
Old 01-25-04, 13:28
gyuan gyuan is offline
Registered User
 
Join Date: Dec 2003
Posts: 454
If you are using the object of ScriptUtils.ASPForm,

Dim Form
Set Form = Server.CreateObject("ScriptUtils.ASPForm")

you need to use

Form.Fields("FieldName")

instead of

Request.Form("FieldName")
Reply With Quote
  #8 (permalink)  
Old 01-25-04, 23:50
ynk1121 ynk1121 is offline
Registered User
 
Join Date: Jan 2004
Location: NY
Posts: 5
i tryed form.fields and it gave me
error:
Object doesn't support this property or method: 'Fields'

im at the verge of giving up. i hate stupid computers :0(
Reply With Quote
  #9 (permalink)  
Old 02-09-04, 14:55
moonshadowzz moonshadowzz is offline
Registered User
 
Join Date: Feb 2004
Posts: 2
What ASP is trying to tell you is that you can't use request.form at all when doing a request.binary. I ran into this problem myself when trying to upload files and write information into Access. Here's the workaround:

Create a form that gets the information (just the information without a file form field). Set this forms action to another ASP page where your'll convert the request.form information to session("") information. Redirect to another ASP form where you'll write the session information into form fields that look just like the original form, but now has a file form field. This way when you POST it will take the session information and put it to whatever you'd like and still perform the upload.

If you didn't get what I'm saying, contact me and I'll walk you through it. I was banging my head against the wall with this one too.

Bobbie
Reply With Quote
  #10 (permalink)  
Old 02-13-04, 16:44
ynk1121 ynk1121 is offline
Registered User
 
Join Date: Jan 2004
Location: NY
Posts: 5
yea, im lost. can you give a little more detail.
thanks
~Brian
Reply With Quote
  #11 (permalink)  
Old 02-13-04, 17:42
moonshadowzz moonshadowzz is offline
Registered User
 
Join Date: Feb 2004
Posts: 2
Ok Create a new ASP page with your upload form. Don't add a file field to the form. Set the action of the form to changeinfo.asp.

Changeinfo.asp will have the following code:

session("id")=request.form("id")
session("id2")=request.form("id2")
{Keep adding the above lines with different form variagles until you're done.}
response.redirect("uploadform.asp")

Uploadform.asp can have a table that's set to mimick the look of the form. In the cells add <%=session("id")%> for each form variable to carry over. Add the file field now. Set the action to whatever you use to upload. To add the information to the database:
{rs should be defined as the Server.CreateObject}
rs.AddNew
rs("fieldname")=session("id")
{keep adding}
rs.update
conn.close
set conn = nothing
set sql = nothing

That should help. Need more? Email me.
Bobbie
Reply With Quote
  #12 (permalink)  
Old 02-16-04, 08:17
Bullschmidt Bullschmidt is offline
Guru
 
Join Date: Jun 2003
Location: USA
Posts: 1,032
Just in case you need to switch to another uploading solution or look at how things are done here is another resource:

ASP File Upload Using VBScript by John R. Lewis - 7/10/2000
http://aspzone.com/posts/160.aspx
__________________
J. Paul Schmidt, Freelance Web and Database Developer
www.Bullschmidt.com
Access Database Sample, Web Database Sample, ASP Design Tips
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On