Solved

<form enctype="multipart/form-data"> error: Object required: ''

Posted on 2006-06-30
21
1,535 Views
Last Modified: 2011-09-20
Hello Everyone, I'm using <form enctype="multipart/form-data">
and also I'm using Free ASP UPLOAD:  http://www.freeaspupload.net/freeaspupload/documentation.asp

However I get this error:  Any ideas what I'm doing wrong?!?

Microsoft VBScript runtime error '800a01a8'

Object required: ''

/investment/Proposals.asp, line 100

This is my code:

Set Upload = New FreeASPUpload
Upload.Save("m:\angie\NG")              <---this is a virtual directory on my web server, does it need WRITE permissions?

dim lName, fName, Title, Company, Address, City, USState, ZipCode
dim Phone, Fax, Email, Comments, Attachment
dim DateSubmitted
dim strBody1

'Receiving values from the COMMENTS FORM, assign the user's answers to variables
fName = Upload.Form("FName")
lName = Upload.Form("LName")
Title = Upload.Form("Title")
Company = Upload.Form("CompanyName")
Address = Upload.Form("Address")
City = Upload.Form("City")
USState = Upload.Form("State")
ZipCode = Upload.Form("ZipCode")
Phone = Upload.Form("PhoneNumber")
Fax = Upload.Form("Fax")
Email = Upload.Form("Email")
Comments = Upload.Form("Comments")
DateSubmitted = Date()


'angie H -- should be be attach1 or attachment?
Attachment = Upload.Form("attach1")
0
Comment
Question by:Gemini532
21 Comments
 

Author Comment

by:Gemini532
ID: 17021061
I"m also getting this error:
ADODB.Stream error '800a0bbc'

Write to file failed.

/investment/freeaspupload.asp, line 63
0
 

Author Comment

by:Gemini532
ID: 17021126
this is where the I get this write to file failed error:            streamFile.SaveToFile path & fileItem.FileName, 2

This function:
I don' t get the other error anymore...  Maybe not yet...

      Public Sub Save(path)
            Dim streamFile, fileItem

            if Right(path, 1) <> "\" then path = path & "\"

            if not uploadedYet then Upload

            For Each fileItem In UploadedFiles.Items
                  Set streamFile = Server.CreateObject("ADODB.Stream")
                  streamFile.Type = 1
                  streamFile.Open
                  StreamRequest.Position=fileItem.Start
                  StreamRequest.CopyTo streamFile, fileItem.Length
                  
'angie test
                  'response.write path
                  'response.write("<br>" & fileItem.FileName)
                  'response.end()

                  streamFile.SaveToFile path & fileItem.FileName, 2

                  streamFile.close
                  Set streamFile = Nothing
                  fileItem.Path = path & fileItem.FileName
             Next
      End Sub
0
 
LVL 6

Expert Comment

by:inviser
ID: 17021174
<form enctype="multipart/form-data"> should be: <form enctype="multipart/form-data" method="post" action="<wherever_your_want>">

Yes, you do need to have write permissions for IUSR_<your_machine> set in windows. Additionally, make sure the dir has write permissions set in IIS
0
 
LVL 25

Expert Comment

by:kevp75
ID: 17021953
inviser has it.

another thing to check for is the virtual path.  Looks like you have a mapped drive (m:), make sure this is not a drive on another computer.  I've often noticed that if there is a mapped drive to another computer the script will fail, only because IUSR_machineA has access to read.write the folder, but the same user on machineB would also have to have those writes.
0
 
LVL 6

Expert Comment

by:darkeryu
ID: 17026779
Hi:

usually you can not using network drive to save the files,
also you need open the permission for everyon full control..

thanks
0
 

Author Comment

by:Gemini532
ID: 17030670
So would it be better if I use a folder on my computer?  C:/interpub/wwwroot/angie/comments   ?
But that means that every file sent by this application will be saved on my computer?

Is there a way to save them only temporarily and have them deleted from the folder after 5 days for instance?

Because I really just want the people who use this form to be abbe to attach files and send them through email, I don't want these files to be saved anywhere, but there is no way to do this without saving the files in a folder first, am I right?

Therefore I chose a network folder, because I thougth there's plenty of space on the network, while there's not much space on my computer...



0
 

Author Comment

by:Gemini532
ID: 17030753
'I changed the code to this, but so far I'm not having any luck...
Attachment = Upload.Form("attach1")
Set Upload = New FreeASPUpload
Upload.Save("C:\INETPUB\WWWROOT\angie")
0
 

Author Comment

by:Gemini532
ID: 17030755
I gave everyone write permissions...  
0
 

Author Comment

by:Gemini532
ID: 17030772
This is the new error:

Microsoft VBScript runtime error '800a01a8'

Object required: ''

/investment/Proposals.asp, line 100


This is where it's coming from:
Attachment = Upload.Form("attach1")

It just doesn't like Upload.Form     althought that is what the instructions said to use...?!?!?
0
 

Author Comment

by:Gemini532
ID: 17030990
I did some research on how to change IUSR since I had no idea what that was, and I Found that it's very risky to change it: or so this article states: http://support.microsoft.com/kb/275139/en-us  "If you change the IUSR account on an Application Center server, authentication failures may result"  

I am starting to think that I don't have the skills to start changing something like IUSR, and if something goes wrong I will have no know how to fix it...

All this is because I am using Free ASP Upload to upload attachments to an email sent by a web form.  I've never done this before, is it something that's very complex?  Can you walk me through the steps?  I don't think I know what I'm doing...  I created a folder in C:\INETPUB\WWWROOT\angie and I called it angie.  I went to "Web Sharing" and gave it write permissions.  Then I went to "SECURITY," and gave EVERYONE write permission, is there anything I missed?  
So the changes to IIS apply to IIS on my computer?  How do I get to it?
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 25

Expert Comment

by:kevp75
ID: 17031347
1st things 1st.

the reason you are getting this error is this:
Attachment = Upload.Form("attach1")
Set Upload = New FreeASPUpload
Upload.Save("C:\INETPUB\WWWROOT\angie")

you need to move the line Attachment = Upload.Form("attach1") to be below the Set Upload, so like this:


Set Upload = New FreeASPUpload
Attachment = Upload.Form("attach1")
Upload.Save("C:\INETPUB\WWWROOT\angie")

2nd.....right click the folder, got to the Security tab, add the user IUSR_machine name, and then give them read/write/modify access to the folder.
0
 

Author Comment

by:Gemini532
ID: 17032072
Right now the users are Administrators, Everyone, System, should I remove all these users and start from scratch and add IUSR_marchine name as you said?
0
 

Author Comment

by:Gemini532
ID: 17032193
I did both of these, and I'm getting this error:

ADODB.Stream error '800a0bbc'

Write to file failed.

/investment/freeASPUpload.asp, line 69
0
 

Author Comment

by:Gemini532
ID: 17032277
This is my code.  I included "freeASPUpload.asp" and I followed its instructions, I'm using Upload.Form(), but it's still not working...  
<!-- #include file="freeASPUpload.asp" -->
<%
dim fName, Attachment
dim DateSubmitted
dim strBody1

Set Upload = New FreeASPUpload
Attachment = Upload.Form("attach1")
Upload.Save("C:\INETPUB\WWWROOT\angie")

fName = Upload.Form("FName")
DateSubmitted = Date()

'*********DATABASE CONNECTION************
dim objConn
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open "fake","fake","fake"
      
requestSQL = "INSERT into [Proposals] (FirstName, AttachedFiles, DateSubmitted) values ('" & _
replace(fName, "'", "''") & "', '" & replace(Attachment, "'", "''") & "', '" & replace(DateSubmitted, "'", "''") & "')"

objConn.Execute requestSQL
objConn.Close
Set objConn = Nothing

'**************Re-open Connection to Start Email Code*******
dim conect, CommentsId
Set conect = Server.CreateObject("ADODB.Connection")
conect.Open “fake","fake","fake"

'On Error Resume Next
sqlError = "select * from [Proposals] where [Proposals].[FirstName] = ('" & replace(fName, "'", "''") & "') and [Proposals].[Comments] LIKE ('" & replace(Comments, "'", "''") & "') "

Set rsErrorCheck = Server.CreateObject("ADODB.Recordset")
rsErrorCheck.Open sqlError, conect

'Long recordset counting using a simple loop by Barry Wright
Dim strCount
strCount = 0
While NOT rsErrorCheck.EOF AND NOT rsErrorCheck.BOF
      strCount = strCount + 1
      rsErrorCheck.MoveNext()
Wend

function sendEmail(body, Recipient1)
            'JMAIL CODE ADDED 7-19-2001 BY MICHAEL LABMAN TO REPLACE CDONTS
            set objMail=Server.CreateObject("Jmail.SMTPMail")
            if Err.number <> 0 then
                  Response.Write("<BR>Error Sending Mail <BR>")
            else
        
                  objMail.ServerAddress = "fake.fake.fake"
                  objMail.AddRecipient("fake@fake.fake")      
                  objMail.Sender = "blah@blah.blah"
                  objMail.Subject="Request"
                  objMail.Body=body
                  objMail.AddAttachment Attachment, f_name
                  'objMail.AddAttachment(Server.MapPath(Attachment))      
                  objMail.Execute
            end if
            set objMail=nothing
end function
dim Recipient1

if strCount > 0  then  
'********************
            dim emailBody
            dim strBody
            
            strBody= "Name: " & fName
            strBody=strBody & chr(10) & "Date Submitted: " & DateSubmitted & vbCrLf

            emailBody= strBody
            sendEmail emailBody, Recipient1  'call function, send email if the data was submitted correctly
else      ' (RecordCount = -1 means that ADO could not find any records)
      
            noDataEBody =  "The proposal you submitted did not reach the database."
                  
            sendEmail noDataEBody, Recipient1  'call function, send email if the data did not make it to the database
end if

rsErrorCheck.close
set rsErrorCheck = nothing
conect.Close
Set conect = Nothing
%>

Your proposal has been submitted!
0
 
LVL 25

Accepted Solution

by:
kevp75 earned 500 total points
ID: 17032562
ok, is this the actual code you are using?

if it is, you need to make some changes.
1st off is this function:
function sendEmail(body, Recipient1)
          'JMAIL CODE ADDED 7-19-2001 BY MICHAEL LABMAN TO REPLACE CDONTS
          set objMail=Server.CreateObject("Jmail.SMTPMail")
          if Err.number <> 0 then
               Response.Write("<BR>Error Sending Mail <BR>")
          else
       
               objMail.ServerAddress = "fake.fake.fake"   '<----this needs to be a real SMTP server
               objMail.AddRecipient("fake@fake.fake")' <-------this is the recipient that you are setting with the function.    
               objMail.Sender = "blah@blah.blah"
               objMail.Subject="Request"
               objMail.Body=body
               objMail.AddAttachment Attachment, f_name
               'objMail.AddAttachment(Server.MapPath(Attachment))    
               objMail.Execute
          end if
          set objMail=nothing
end function

change it to:
function sendEmail(body, Recipient1)
          'JMAIL CODE ADDED 7-19-2001 BY MICHAEL LABMAN TO REPLACE CDONTS
          set objMail=Server.CreateObject("Jmail.SMTPMail")
          if Err.number <> 0 then
               Response.Write("<BR>Error Sending Mail <BR>")
          else
       
               objMail.ServerAddress = "smtp.server.com"
               objMail.AddRecipient(Recipient1)    
               objMail.Sender = "blah@blah.blah" '<------you will need to change this to an actual email address
               objMail.Subject="Request"
               objMail.Body=body
               objMail.AddAttachment Attachment, f_name
               'objMail.AddAttachment(Server.MapPath(Attachment))    
               objMail.Execute
          end if
          set objMail=nothing
end function

2nd.
use FSO to get the file you are trying to attach.  Just because you've uploaded Attachment, does not mean it will automatically read it from the uploaded directory, as all it is set to do is get the name of the file you are trying to attach.

all this said, and it will work.



0
 

Author Comment

by:Gemini532
ID: 17042216
they are actual email addresses, but they're secret, so I couldn't show them here.... That's why I change to fake, or blah...   hehe
What is FSO?
And the attachement is not uploaded.  I looked in the folder (the uploaded directory) where it should be and it's not there.  
0
 
LVL 25

Expert Comment

by:kevp75
ID: 17042755
FSO is the file scripting object.

it's not uploaded?  You may have permission issues on the folder you are trying to upload to.  I wouldn't make the webroot folder the storage folder though.  You should have something like /wwwroot/uploads

then you will need to right click the folder, go to the security tab, hit add, find IUSR_machinename, and give them full control.

then try the upload again
0
 

Author Comment

by:Gemini532
ID: 17043944
I got it to UPLOAD  :)
But now I have to attach the file to the email from my web server folder

dim fileName
objMail.AddAttachment(Server.MapPath(fileName))

But I'm not sure how to get the file name from the path...

In the "freeASPUpload.asp" file from the FREE ASP UPLOAD application http://www.freeaspupload.net/freeaspupload/documentation.asp, they have a function that does it and they store it in a variable called "FileName"

      'Calls Upload to extract the data from the binary request and then saves the uploaded files
      Public Sub Save(path)
            Dim streamFile, fileItem

            if Right(path, 1) <> "\" then path = path & "\"

            if not uploadedYet then Upload

            For Each fileItem In UploadedFiles.Items
                  Set streamFile = Server.CreateObject("ADODB.Stream")
                  streamFile.Type = 1
                  streamFile.Open
                  StreamRequest.Position=fileItem.Start
                  StreamRequest.CopyTo streamFile, fileItem.Length
                  
'angie test
                  'response.write("<br>" & path & fileItem.FileName)
'                  response.end()

                  streamFile.SaveToFile path & fileItem.FileName, 2

                  streamFile.close
                  Set streamFile = Nothing
                  fileItem.Path = path & fileItem.FileName
             Next
      End Sub
0
 
LVL 25

Expert Comment

by:kevp75
ID: 17043989
that's only to save the file to the server, you can't use it to get the name for you once it's there

that's why i mentioned the FSO, please see links:
http://www.tutorial-web.com/asp/fso/
http://www.w3schools.com/asp/asp_ref_filesystem.asp
0
 

Author Comment

by:Gemini532
ID: 17044692
This is my code, but it doesn't work. there is no value for the "pathName" variable
dim fileName
dim pathName

pathName = Upload.Form("attach1")
response.write pathName

pathName = "c:\winnt\cursors\3dgarro.cur"
Set fs=Server.CreateObject("Scripting.FileSystemObject")
fileName = fs.GetFileName(pathName)
response.write fileName
set fs=nothing

It comes from "submit.asp"
<FORM METHOD="POST"  ACTION="Proposals.asp" onSubmit="return validate(this)" id = "ProposalsForm" name = "ProposalsForm" ENCTYPE="multipart/form-data" >
 <INPUT TYPE="FILE" NAME="attach1" VALUE="" size = "32">
<INPUT type="submit" value="Upload" name="submit" style = "background:#0D6B9C; font-weight:bold; color:#FFFFFF;">
</FORM>
Any ideas why this is happening?  and how to fix it?  All the other variables (like first name, last name, etc...) work OK, but this one doesn't....?!!?
0
 

Author Comment

by:Gemini532
ID: 17044767
I DID IT!  I JUST ADDED A HIDDEN VARIABLE
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now