|
|
|
|
|
|
![]() |
#1 |
They have the Internet on computers, now?
Join Date: Apr 2005
Posts: 148
|
How to add image attachment within a form
I have created a form with my hosts form mail utility but want to include fields that allow image attachments. How can I do this?
|
![]() |
![]() |
![]() |
#2 |
Me fail English? That's unpossible!
|
Code:
<input accept="image/gif,image/jpeg,image/png" style="width:240" name="picture" type="file" class="inputfield"> |
![]() |
![]() |
![]() |
#3 |
a.k.a. Sparky
Join Date: Sep 2004
Location: West Palm Beach, FL, USA
Posts: 2,396
|
HTML:
Code:
<form method="post" enctype="multipart/form-data"> <input name="uploadedfile" type="file"> <input type="submit" name="submit" value="Upload"> </form> Code:
if (!(file_exists($_FILES['uploadedfile']['tmp_name']))) { $error .= "Please try again, I didn't get a file. "; } else { // do something with the file }
__________________
SnapReplay.com a different way to share photos - iPhone & Android |
![]() |
![]() |
![]() |
#4 |
They have the Internet on computers, now?
Join Date: Apr 2005
Posts: 148
|
Howling Wulf,
I have tried your input field and submitted a form but the resulting output gives me a local file that I can't open. ie: E:\\My Pictures\\2006-03-23, Rumbelinas II\\Rumbelinas II 001.jpg since this file is on my computer only how could I open an image if somebody submitted one to me and it was located on their local harddrive, not a server? cd34, I do not understeand where I would put your code(s) in my form |
![]() |
![]() |
![]() |
#5 |
Me fail English? That's unpossible!
|
The input field is put between the <form> tags, and you'll need code to handle the uploaded file. cd34's post has full details you need.
|
![]() |
![]() |
![]() |
#6 |
They have the Internet on computers, now?
Join Date: Apr 2005
Posts: 148
|
But where do I put cd34's code?
|
![]() |
![]() |
![]() |
#7 |
a.k.a. Sparky
Join Date: Sep 2004
Location: West Palm Beach, FL, USA
Posts: 2,396
|
Generally, I would do something like
Code:
<?php if (!(file_exists($_FILES['uploadedfile']['tmp_name']))) { $error .= "Please try again, I didn't get a file. "; } else { // do something with the file header("Location: /thanks_for_your_upload.html"); exit; } ?> Upload your file: <form method="post" enctype="multipart/form-data"> <input name="uploadedfile" type="file"> <input type="submit" name="submit" value="Upload"> </form>
__________________
SnapReplay.com a different way to share photos - iPhone & Android |
![]() |
![]() |
![]() |
#8 |
They have the Internet on computers, now?
Join Date: Apr 2005
Posts: 148
|
So do I place the php code in a seperate file? Do I point my form action to this php file? Right now here is my form:
<form action="http://formmail.servage.net/" method="POST" enctype="multipart/form-data" name="Application" > <input type=hidden name="id" value="8460"> <input type=hidden name="subject" value="FORM SUBJECT"> <table bgcolor="#a04d2d" cellpadding="7" width="750"> <tr> <td> <div align="right"> <font face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular" color="#FFFFFF"><b>Attach Photo 1:</b></font></div></td> <td><font face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular"> <input accept="image/gif,image/jpeg,image/png" style="width:240" name="picture1" type="file" class="inputfield"> </font></td> </tr> <tr> <td> <div align="right"> <font face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular" color="#FFFFFF"><b>Attach Photo 2:</b></font></div></td> <td><font face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular"> <input accept="image/gif,image/jpeg,image/png" style="width:240" name="picture2" type="file" class="inputfield"> </font></td> </tr> <tr> <td align="right"><input name="submit" type="submit" value="Submit"> <input name="reset" type="reset"> <br> <p><br> </p> <p></p></td> </tr> </table> </form> and here is my output: Below is the result of your feedback form. It was submitted by Unknown Stranger (nobody@servage.net) on January 29th, 2007 submit: Submit email: nobody@servage.net realname: Unknown Stranger if I remove the enctype="multipart/form-data" I at least get a return of an image pointing to a local file: Below is the result of your feedback form. It was submitted by Unknown Stranger (nobody@servage.net) on January 29th, 2007 picture1: C:\\Documents and Settings\\Al\\My Documents\\Invoices\\inv22.jpg picture2: C:\\Documents and Settings\\Al\\My Documents\\Invoices\\inv23.jpg submit: Submit email: nobody@servage.net realname: Unknown Stranger I want people to upload files with their forms. Is this a server issue as the form is being pointed to a page controlled by them through the form action attribute? |
![]() |
![]() |
![]() |
#9 |
They have the Internet on computers, now?
Join Date: Apr 2005
Posts: 148
|
|
![]() |
![]() |
![]() |
|
|