Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2006-06-30
21
Medium Priority
?
1,566 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
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 2000 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
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…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

721 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