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 = "someone@gmail.com"; 

$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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.