Solved

Photos Attached to Email

Posted on 2004-08-20
8
258 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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

790 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