Solved

Photos Attached to Email

Posted on 2004-08-20
8
257 Views
Last Modified: 2010-04-09
I have been searching for a while now (possibly not hard enough) and can't seem to find what I'm looking for.

I would like to know how to allow users to attach images to an email on my contact page.  This would be so that users could "Submit Photos" to me (the webmaster) so that I can post them on the website.

So, basically I know the HTML portion of it (or the basics of it)

<form name="photoSubmit" action="../scripts/photosubmit.php">
Your Name: <input name="name" type="text" size="30"></input>
Your Email: <input name="email" type="text" size="30"></input>
Photo Title: <input name="ptitle" type="text" size="30"></input>
Photo Description: <textarea name="pdescrip" type="text" rows="20" size="50"></textarea>
Photo Copyright: <input name="copyright" type="text" onClick="value=''" value="This Photo is Copyright 2004 SOMEONE"></input>
<input type="Submit" name="Send" label="Submit the Photos"></input>
<input type="Reset" name="Reset" label="Reset the Form"></input>
</form>

Now, the PHP will be the regular mail script, with the normal stripping of slashes, and sending it to a pre-determined email address.  The only part I don't get is creating the "Attachment:" input selection, and how to add the PHP to it to allow the submission of the image.

Any and all help would be appreciated.

~Brett
0
Comment
Question by:bpat1434
8 Comments
 
LVL 19

Expert Comment

by:webwoman
ID: 11857528
You need a special upload component to handle the file. I'm pretty sure there's one for PHP. Your server will also need to be able to handle uploads.
0
 

Author Comment

by:bpat1434
ID: 11857546
Any idea as to what some good ones are, and how/where i can check for the ability to handle uploads?

~Brett
0
 
LVL 10

Accepted Solution

by:
daleoran earned 50 total points
ID: 11860287
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 3

Expert Comment

by:Boris Aranovich
ID: 11871196
well, there are several steps.
First of all, you have to add a file field to the form
<input type="file" name="attachmentfile" />

then, to the <form> tag, you need to add enctype="multipart/form-data", and also i'd suggest using method="post":
<form name="photoSubmit" action="../scripts/photosubmit.php" method="post" enctype="multipart/form-data">

then, you will have 2 ways.
Either you'll have to save the uploaded file somewhere (http://www.php.net/manual/en/features.file-upload.php) and then just add <img src="someurl" /> to the mail, if you have it as text/html mail,
or the 2nd method, is creating a Multipart MIME e-mail, and attaching the file data in base64_encode() form to the body (http://www.theukwebdesigncompany.com/articles/php-file-attachments.php and http://www.zend.com/zend/spotlight/sendmimeemailpart1.php)

Hope this helps
0
 
LVL 9

Expert Comment

by:DrWarezz
ID: 11874166
I recommend using JSP.

[r.D]
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 12803944
Why would you recommend another server language when php is installed, runs and the person asking seems to know it?
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Suggested Solutions

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…

777 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