Sending attachement to email
Hi,
I'm making a fileupload function that will create a watermark and border on the image uploaded.
And then it is supposed to send an email with the image to an email that is typed in a field.
But it comes with an error, it works individually, but when I put the mail function and the watermark thing together it doesn't work.
This is the error:
Parse error: syntax error, unexpected '}' in /home/www/wearecrunch.dk/watermark/somefile.php on line 52
And this is my code:
PHP Code:
<?php
include_once( 'class/class.upload.php' );
if(isset($_POST['upload'])){
$handle = new upload($_FILES['file_name']);
$handle->allowed = array('image/*');
if($handle->uploaded){
$handle->image_border = 5; // defining border width
$handle->image_border_color = '#F58462'; // defining border color
$handle->image_watermark = 'site-logo.png'; // watermark image src
$handle->image_watermark_position = 'BR'; // watermark image position again "B" for bottom and so on.
$handle->image_resize = true; // making resize function to true
$handle->image_x = 160; // making width to 160px
$handle->image_y = 160; // making hight to 160px
$handle->process('uploads/');
if ($handle->processed) {
//$message = '<div class="center"><p>Border color #F58462 added successfully</p><img src="uploads/'.$handle->file_dst_name.'" alt="" /></div>';
//*** Uniqid Session ***//
$strSid = md5(uniqid(time()));
$to = $_POST['mail'];
$from = 'my@gmail.com';
$subject = 'the subject';
$headers = 'From: '.$from. "\r\n" . 'Reply-To: '.$from. "\r\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: multipart/mixed; boundary=\"".$strSid."\"\n\n";
$headers .= "This is a multi-part message in MIME format.\n";
$headers .= "--".$strSid."\n";
$headers .= "Content-type: text/html; charset=utf-8\n";
$headers .= "Content-Transfer-Encoding: 7bit\n\n";
if($_FILES["file_name"]["name"] != "") {
$strFilesName = $_FILES["file_name"]["name"];
$strContent = chunk_split(base64_encode(file_get_contents($_FILES["file_name"]["tmp_name"])));
$headers .= "--".$strSid."\n";
$headers .= "Content-Type: application/octet-stream; name=\"".$strFilesName."\"\n";
$headers .= "Content-Transfer-Encoding: base64\n";
$headers .= "Content-Disposition: attachment; filename=\"".$strFilesName."\"\n\n";
$headers .= $strContent."\n\n";
}
$flgSend = @mail($to, $subject, $message, $headers); // @ = No Show Error //
if($flgSend)
//echo $message;
}
}
}
?>