PDA

View Full Version : image to form



hysteria75067
11-03-2009, 03:05 PM
i am having an issue. i am sure this has been done a million and one times. i am not too good at website design and scripts. so i understand some basic stuff. was wondering if someone can help me with a form.
what i am looking to do is have a user fill out a form and click submit and it sends it to my email. easy! that i can do.
now the problem is-- i was wanting the same user to be able to choose a file (upload) and it is submitted with their info on the form. so when i open my email i see the image as an attachment. is this even possible?
can anyone help?
i know my server supports php. i don't understand cgi, cgi-bin either.

as i said-- i am pretty basic-- so step by step would be very helpful when routing and uploading the files/scripts i need




<FORM ACTION="/cgi-sys/formmail.cgi" METHOD="POST">
<input type=hidden name="recipient" value="yourmail@yourdomain.com">
<input type=hidden name="subject" value="Siteground Test">
<BR>
<BR>
<TABLE>
<TR>
<TD>Name:</TD>
<TD>
<input type=text name="name">
</TD>
</TR>
<TR>
<TD>Feedback:</TD>
<TD>
<input type=text name="feedback">
</TD>
</TR>
<TR>
<TD>
<input type="reset" value="Reset" name="Reset">
</TD>
<TD>
<input type="submit" value="Submit" name="Submit">
</TD>
</TR>
</TABLE>
</FORM>

djr33
11-03-2009, 05:52 PM
This is possible, but complex. In short, file attachments to emails are difficult to get working in PHP because it must be done through a few steps.

First, look up a form mailer in PHP and get that working. (On YOUR server, NOT hosted somewhere else, or the attachment probably won't be allowed.)

Second, loop up information on how to upload files in PHP.

Third, and here is the hardest part, loop up information on attachments in php-generated email.

Information on all of this is available on php.net (a great reference for do-it-yourself work), and there are also tutorials available (use google, there are lots) for each of these, but you may not get one that explains ALL of it, so go step by step.

It's very possible, just might take a little while to get setup.

Once you have a little clearer idea how to approach the problem, feel free to ask for more help with the specifics.

Also, the html is almost entirely unrelated to this, just how you submit your data. Any html form will work as long as you have the required parts. A <input type="file"> tag will give you the way to upload an image. Look at the tutorials for more information.

prasanthmj
11-04-2009, 04:18 AM
There are a few extra steps for handling file upload and then attaching a file to the email.

There is a library 'Pear' for PHP. Using this library, it is easier.

The page below has some sample code:
How to create PHP email form with file attachment (http://www.html-form-guide.com/email-form/php-email-form-attachment.html)