c_pattle Posted May 27, 2010 Share Posted May 27, 2010 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"; } ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.