I am trying to upload a file to the webserver and then send it via email.
I am using ASPUpload (persists)
here is my code
the form
Code:
<FORM method="Post" action="resultspage.asp" ENCTYPE="multipart/form-data name="Recruiter">
<TABLE width="100%" border="0">
<TR><TD width="30%"><div align="right">Email:</div></TD>
<TD width="70%"><INPUT TYPE="text" name="Email" size="50"></TD></TR>
<TR><TD width="30%"><div align="right">First Name:</div></TD>
<TD width="70%"><INPUT TYPE="text" name="FirstName" size="50"></TD></TR>
<TR><TD width="30%"><div align="right">Last Name:</div></TD>
<TD width="70%"><INPUT TYPE="text" name="LastName" size="50"></TD></TR>
<TR><TD width="30%"><div align="right">Position APPlying For:</div></TD>
<TD width="70%"><INPUT TYPE="text" name="Position" size="50"></TD></TR>
<TR> <TD width="30%"><div align="right">Resume:</div></TD>
<TD width="70%"><INPUT TYPE="file" name="Resume" size="35"></TD></TR>
<TR><TD width="30%" valign="top"><div align="right">Comments:</div></TD>
<TD width="70%"><textarea name="Comments" cols="50" rows="5"></textarea></TD></TR>
</TABLE>
<P>
<INPUT TYPE="submit" name="Submit" value="Submit">
<INPUT TYPE="reset" name="Reset" value="Reset">
</P>
</FORM>
Here is the code in th back end
Code:
<%
DIM objRSr, File, Upload, Count, Ext
DIM Mail, strMsgHeader
Set Upload = Server.CreateObject("Persits.Upload.1")
Count = Upload.SaveVirtual("/files/")
Upload.IgnoreNoPost = True
IF NOT Count=0 THEN
FOR EACH File IN Upload.Files
Ext = UCase(Right(File.Path, 3))
IF Ext <> "TXT" AND Ext <> "DOC" THEN
Response.Write Upload.Form("FirstName") & ",<br><br>"
Response.Write "Sorry, your resume " & File.Path & " is not in a .DOC or .TXT format and has not been delivered through our system. Please save your resume in one of these formats and resubmit it."
File.Delete
ELSE
Set objRSr = Server.CreateObject("ADODB.Recordset")
objRSr.Open "tblContact", objConn, , adLockOptimistic, adCmdTable
objRSr.AddNew
objRSr("Data") = "Resumes"
objRSr("Email") = Upload.Form("Email")
objRSr("FirstName") = Upload.Form("FirstName")
objRSr("LastName") = Upload.Form("LastName")
objRSr("Position") = Upload.Form("Position")
objRSr("Comments") = Upload.Form("Comments")
objRSr("DateSubmitted") = Date()
Set File = Upload.Files("fResume")
If Not File Is Nothing Then objRSr("fResume").Value = File.Binary
objRSr.Update
objRSr.Close
Set objRSr = Nothing
Set Mail = Server.CreateObject("Persits.MailSender")
Mail.Host = "localhost"
Mail.From = Upload.Form("Email@email.com")
Mail.AddAddress "gentex@tpg.com.au"
Mail.Subject = "Resume"
strMsgHeader = "This email was delivered from your website." & vbCrLf & vbCrLf
Mail.Body = strMsgHeader & "Email: " & Upload.Form("Email") & vbCrLf & "First Name: " & Upload.Form("FirstName") & vbCrLf & "Last Name: " & Upload.Form("LastName") & vbCrLf & "Position: " & Upload.Form("Position") & vbCrLf & vbCrLf & "Comments: " & Upload.Form("Comments")
IF Count > 0 THEN
Mail.AddAttachment Upload.Files(1).Path
On Error Resume Next
Mail.Send
IF Err <> 0 THEN
Response.Write "There was an error sending your message. Please visit our Contact Us page and send a message to our Webmaster to report this error: <B>" & Err.Description & "</B>"
ELSE
Response.Write Upload.Form("FirstName") & ","
Response.Write "<p>Thank you for contacting our recruiter. Your resume has been received and will be reviewed shortly. If we have a position is available that matches your skills, we will contact you to schedule an interview. We keep all resumes on file for a period of 6 months, please feel free to resubmit your resume after this time for future consideration.</p>"
File.Delete
END IF
END IF
END IF
NEXT
%>
<P>
<%
' This is a nice way to Personalize your FORM.
' It disPlays the Persons name before your message.
strName = Request.Form("FirstName")
Response.Write strFirstName
END IF
%>,</P>
<P>Thank you for emailing us your resume.</P>
And the error i get
Error Type:
Persits.Upload.1 (0x800A003D)
Wrong Content-Type. Make sure you have included the attribute ENCTYPE="multipart/form-data" in your form.
/resultspage.asp, line 5
Browser Type:
Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 1.0.3705; InfoPath.1; .NET CLR 2.0.50727)
Page:
POST 165 bytes to /resultspage.asp
POST Data:
Email=test&FirstName=etst&LastName=tets&Position=s dhgj&Resume=C%3A%5CDocuments+and+Settings%5CAdmini strator.SALES100%5CDesktop%5Ctest.txt&Comments=dcs d&Submit=Submit
Now I have no idea why on earth this comming up all th reading i have done, there is no reason for this that i can find.
Any help is appreciated
Thanks
Brad