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='rabid-turtle@shaw.ca' /> <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 = 'noreply@nicaprojects.com';$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: noreply@nicaprojects.com\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 Quote Link to comment 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. Quote Link to comment 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? Quote Link to comment Share on other sites More sharing options...
Andrius Posted November 29, 2006 Author Share Posted November 29, 2006 ^bump Quote Link to comment 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. Quote Link to comment 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! 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.