Andrius Posted November 29, 2006 Share Posted November 29, 2006 ok on index.php I have this code and yes $image is assigned and working as it should (displays news images on the main page)[code]<form id='imageform' name='imageform' method='post' action='http://www.nicaprojects.com/image_mailer.php'> <BUTTON name='mail_button' type='submit'>Send to friend</BUTTON> <input name='to' type='hidden' value='[email protected]' /> <input name='image' type='hidden' value='/news_images/$image' /></form>[/code]then on image_mailer.php I have this code[code]<?PHP $to = $_POST['to'];$from = '[email protected]';$image = $_POST['image'];$subject = 'Image of Nicaragua I thought you may like.'; $bound_text = "jimmyP123"; $bound = "--".$bound_text."\r\n"; $bound_last = "--".$bound_text."--\r\n"; $headers = "From: [email protected]\r\n"; $headers .= "MIME-Version: 1.0\r\n" ."Content-Type: multipart/mixed; boundary=\"$bound_text\""; $message .= "If you can see this MIME than your client doesn't accept MIME types!\r\n" .$bound; $message .= "Content-Type: text/html; charset=\"iso-8859-1\"\r\n" ."Content-Transfer-Encoding: 7bit\r\n\r\n" ."Hey! Just forwarding you a picture of Nicaragua I thought you may like!\r\n" .$bound; $file = file_get_contents("$image"); $message .= "Content-Type: image/jpg; name=\"nicaragua.jpg\"\r\n" ."Content-Transfer-Encoding: base64\r\n" ."Content-disposition: attachment; file=\"nicaragua.jpg\"\r\n" ."\r\n" .chunk_split(base64_encode($file)) .$bound_last; if(mail($to, $subject, $message, $headers)) { echo 'MAIL SENT'; } else { echo 'MAIL FAILED';} ?>[/code]but when the whole thing runs I get this result:Warning: file_get_contents(): open_basedir restriction in effect. File(/news_images/LaSaltaDeEstanzuelaWaterfall (Small).jpg) is not within the allowed path(s): (/home/httpd/vhosts/nicaprojects.com/httpdocs:/tmp) in /home/httpd/vhosts/nicaprojects.com/httpdocs/image_mailer.php on line 31Warning: file_get_contents(/news_images/LaSaltaDeEstanzuelaWaterfall (Small).jpg): failed to open stream: Operation not permitted in /home/httpd/vhosts/nicaprojects.com/httpdocs/image_mailer.php on line 31MAIL SENT Link to comment https://forums.phpfreaks.com/topic/28815-e-mailing-image-attachment-not-working/ Share on other sites More sharing options...
fert Posted November 29, 2006 Share Posted November 29, 2006 you need to set the permissions to the file so that PHP can access it. Link to comment https://forums.phpfreaks.com/topic/28815-e-mailing-image-attachment-not-working/#findComment-131948 Share on other sites More sharing options...
Andrius Posted November 29, 2006 Author Share Posted November 29, 2006 CHMOD was already 777 to the news_images dir where the image was stored.. any other ideas? Link to comment https://forums.phpfreaks.com/topic/28815-e-mailing-image-attachment-not-working/#findComment-131978 Share on other sites More sharing options...
Andrius Posted November 29, 2006 Author Share Posted November 29, 2006 ^bump Link to comment https://forums.phpfreaks.com/topic/28815-e-mailing-image-attachment-not-working/#findComment-132268 Share on other sites More sharing options...
bljepp69 Posted November 29, 2006 Share Posted November 29, 2006 You might have to set the image path to the full server path - /home/httpd/vhosts/nicaprojects.com/httpdocs/news_images/LaSaltaDeEstanzuelaWaterfall (Small).jpg, instead of simply - /news_images/LaSaltaDeEstanzuelaWaterfall (Small).jpg. Or, if news_images is easily accessable as a relative path from image_mailer.php, try simply 'news_images/$image', or whatever relative variant, insead of the leading '/', which is trying to take it to the root directory. Link to comment https://forums.phpfreaks.com/topic/28815-e-mailing-image-attachment-not-working/#findComment-132276 Share on other sites More sharing options...
Andrius Posted November 29, 2006 Author Share Posted November 29, 2006 you are BRILLIANT!! It was the first / that screwed the whole thing up! thanks so much! Link to comment https://forums.phpfreaks.com/topic/28815-e-mailing-image-attachment-not-working/#findComment-132414 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.