Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 4th, 2007, 05:44 AM
Registered User
 
Join Date: Sep 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Need some help... desprite

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


 
Old September 4th, 2007, 05:55 AM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to vinod_yadav1919 Send a message via Yahoo to vinod_yadav1919
Default

Hii Brad!!

plz check the form tag in ur code i.e
<FORM method="Post" action="resultspage.asp" ENCTYPE="multipart/form-data name="Recruiter">
which should be like
<FORM method="Post" action="resultspage.asp" ENCTYPE="multipart/form-data" name="Recruiter">
double quote(")is with enctype
hope this will help you


Cheers :)

vinod









Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.