php mail attachment? problem
Posted: Fri Apr 06, 2007 4:10 am
feyd | Please use
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
hello there, my name is tyrohansen, a newbe to php. i current working on a script that sends an attachement to my email. fortunately it seems to work but the problem is "[b]I GET ONLY 1KB OF THE WHOLE FILE[/b]", can anyone show me how i can solve this.
this my source below:Code: Select all
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
</head>
<body>
<?php
$to = "tyrohansen@yahoo.com,";
$from = "<webmaster@ventug.com>";
$subject = "Here is your attachment";
$fileatt = $HTTP_POST_FILES["userfile"]["tmp_name"];
$fileatttype = $HTTP_POST_FILES["userfile"]["type"];
$fileattname = $HTTP_POST_FILES["userfile"]["name"];
$headers = "From: $from";
//encoding
$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}\"";
$message = "This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary}\n" .
"Content-Type: text/plain; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$message . "\n\n";
$data = chunk_split( base64_encode( $data ) );
$message .= "--{$mime_boundary}\n" .
"Content-Type: {$fileatttype};\n" .
" name=\"{$fileattname}\"\n" .
"Content-Disposition: attachment;\n" .
" filename=\"{$fileattname}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" .
"--{$mime_boundary}--\n";
//sending email
if( mail( $to, $subject, $message, $headers ) ) {
echo "<p>The email was sent.</p>";
}
else {
echo "<p>There was an error sending the file.</p> <br>$fileattname";
}
?>
</body>
</html>feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]