Jump to content

Problem Mailing Attachments


c_pattle

Recommended Posts

Hey

 

I have an form with the option of adding an attachment.  However I'm having some trouble when trying to send it.  I am getting the following error. 

 

Warning: fread(): supplied argument is not a valid stream resource in /websites/123reg/LinuxPackage21/co/lo/ur/colourbrush.co.uk/public_html/order_success2.php on line 39

 

I have copied my code below

 

<?php
$to = "[email protected]"; 

$att = $_FILES['att'];
$att_path = $_FILES['att']['tmp_name'];
$att_name = $_FILES['att']['name'];
$att_size = $_FILES['att']['size'];
$att_type = $_FILES['att']['type'];

$fp = fopen( $att_path, "rb");
$file = fread( $fp, $att_size );
$fclose ($fp);

$num = md5(time());
$str = "==multipart_Boundary_x{$num}x";

$file = chunk_split(base64_encode($file));

$subject = "You have a new order from " . $_REQUEST['order_company_name']; 

$message = "Company Name:  " . $_REQUEST['order_company_name'] ;

$email = $_REQUEST['order_email'] ; 
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: multipart/mixed;";
$headers .= "boundary=\"{$str}\"\r\n";
//$headers .= " charset=iso-8859-1\r\n";
$headers .= "From: $email"; 
$sent = mail($to, $subject, $message, $headers) ; 
if($sent) 
{print "Thank you.  Your order was sent successfully"; }
else 
{print "Sorry.  We encountered an error sending your mail"; }
?>

Link to comment
https://forums.phpfreaks.com/topic/203060-problem-mailing-attachments/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.