Bringing up PHP GD problem again, help please

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
violet
Forum Newbie
Posts: 24
Joined: Wed May 23, 2007 12:13 pm
Location: Manila, Philippines
Contact:

Bringing up PHP GD problem again, help please

Post by violet »

I'm (still) trying to send a PHP GD image as a form-to-mail attachment. I have this:

Code: Select all

$im = image.php
in my sendmail.php.

I'm using file_get_contents() but I think the parameters in the parentheses shouldn't be:

Code: Select all

$file =	file_get_contents($im, 'rb');
because that way I literally get the contents of $im:

Code: Select all

<?php header("Content-type:image/gif");
	$image = imagecreatetruecolor(231,200) or die ("Cannot create image");
 	$black = imagecolorallocate($image,0,0,0);
	$white = imagecolorallocate($image,255,255,255);

etcetera
Thing is, how do I call/get the processed contents of $im in my sendmail.php?

Help please... :?

P.S.
This is part of my sendmail.php.. Please correct all that looks wrong:

Code: Select all

$file =	file_get_contents($im, 'rb');
ob_start(); 
imagegif($im, '', 70); 
$file = ob_get_clean(); 

$message .=	"Content-Type: image/gif; name=\"image.gif\"\r\n" 
 	."Content-Transfer-Encoding: base64\r\n"
 	."Content-disposition: attachment; file=\$im\r\n"
	."\r\n"
 	.chunk_split(base64_encode($file))
 	.$bound_last; 
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

remove the header("Content-type:image/gif"); from image.php
use require() instead of file_get_contents()
There is no third parameter for imagegif()
You might be interested in http://swiftmailer.sf.net
User avatar
violet
Forum Newbie
Posts: 24
Joined: Wed May 23, 2007 12:13 pm
Location: Manila, Philippines
Contact:

Post by violet »

Thank you thank you thank you, volka! :) I will try this ASAP!

I have tried Swiftmailer but to be completely honest with you, I couldnt' figure out how to use it.. A 'Swiftmailer for Dummies' would probably be very useful :D
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

User avatar
violet
Forum Newbie
Posts: 24
Joined: Wed May 23, 2007 12:13 pm
Location: Manila, Philippines
Contact:

Post by violet »

It worked, volka!!! Image
Post Reply