homepage Welcome to WebmasterWorld Guest from 54.166.111.111
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
Forum Library, Charter, Moderators: ocean10000

Microsoft IIS Web Server and ASP.NET Forum

    
ASP form - need to upload image
aroon




msg:3925758
 4:46 pm on Jun 3, 2009 (gmt 0)

Ok I have an ASP form:

<form method="POST" action="contact.asp">
Fields marked (*) are required

<p>Name:<br>
<input type="text" name="Name">
<p>Email:<br>
<input type="text" name="Email">
<p>Comments:<br>
<textarea name="Comments"></textarea>
<p><input type="submit" name="submit" value="Submit">
</form>
<p>

And the related .ASP file:

<%
Dim EmailFrom
Dim EmailTo
Dim Subject
Dim Name
Dim Email
Dim Comments

' get posted data into variables
EmailFrom = "email@email.com"
EmailTo = "email2@email2.com"
Subject = "Subject"
Name = Trim(Request.Form("Name"))
Email = Trim(Request.Form("Email"))
Comments = Trim(Request.Form("Comments"))

' validation
Dim validationOK
validationOK=true
If (validationOK=false) Then Response.Redirect("error.htm?" & EmailFrom)

' prepare email body text
Dim Body
Body = Body & "Name: " & Name & VbCrLf
Body = Body & "Email: " & Email & VbCrLf
Body = Body & "Comments: " & Comments & VbCrLf

' send email
Dim mail
Set mail = Server.CreateObject("CDONTS.NewMail")
mail.To = EmailTo
mail.From = EmailFrom
mail.Subject = Subject
mail.Body = Body
mail.Send

' redirect to success page
Response.Redirect("mysite.htm?" & EmailFrom)
%>

I need to also be able to upload an image and send it to my email address. How do I do this?

 

bmcgee




msg:3927002
 3:43 am on Jun 5, 2009 (gmt 0)

You will need an upload component installed on the server - something like aspupload

Each component has differences, and slight differences in how you use it. But generally you will change the form encryption method and then you access the image like any other field.

Then after that, you will want to save the image, then send it as an attachment in the email. You can look at cdonts for that. Note that I think cdosys is recommended now in place of cdonts.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved