View Full Version : Form with uploading file field!!! How?

03-23-2006, 02:33 PM
How is this possible? To make a form tha has an upload file field so that the visitor can send a file to a specific email via this form?
I want something like
THIS (http://www.dreamweaverclub.com/dreamweaver-php-form.php) but with a "file upload" field attached to this form

03-23-2006, 08:44 PM
What program and langauge are you using? It also depends on what upload class your host supports!

03-24-2006, 02:22 PM
I am intrested in php language... that's why i mention THIS (http://www.dreamweaverclub.com/dreamweaver-php-form.php) example.
I need something like that

03-27-2006, 10:25 AM
you can do this a number of ways

user can upload a file to your server and you can email a link to it or you can include it by attaching it to the email

which one do you fancy

03-30-2006, 09:43 AM
I prefer a user to be able to attach the file to a email and sent it to my email inbox.

01-12-2007, 01:45 PM
*just bumping this thread*

I want to do this exactly - but theres no answer yet- by attaching it to the email that the php script sends.


01-12-2007, 06:47 PM
from codewalkers

$fileatt = ""; // Path to the file
$fileatt_type = "application/octet-stream"; // File Type
$fileatt_name = ""; // Filename that will be used for the file as the attachment

$email_from = ""; // Who the email is from
$email_subject = ""; // The Subject of the email
$email_txt = ""; // Message that the email has in it

$email_to = ""; // Who the email is too

$headers = "From: ".$email_from;

$file = fopen($fileatt,'rb');
$data = fread($file,filesize($fileatt));

$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";

$headers .= "\nMIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
" boundary=\"{$mime_boundary}\"";

$email_message .= "This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary}\n" .
"Content-Type:text/html; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$email_message . "\n\n";

$data = chunk_split(base64_encode($data));

$email_message .= "--{$mime_boundary}\n" .
"Content-Type: {$fileatt_type};\n" .
" name=\"{$fileatt_name}\"\n" .
//"Content-Disposition: attachment;\n" .
//" filename=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" .

$ok = @mail($email_to, $email_subject, $email_message, $headers);

if($ok) {
echo "<font face=verdana size=2>The file was successfully sent!</font>";
} else {
die("Sorry but the email could not be sent. Please go back and try again!");