logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Coding & Scripting Corner View previous topic :: View next topic
Reply to topic   Topic: php ecard program won't send card image
Author
greygrey



Joined: 28 Mar 2008
Posts: 18

PostPosted: Fri 03 Dec '10 19:58    Post subject: php ecard program won't send card image Reply with quote

Hi,

I'm a self taught developer, using Apache, php5.2 and Windows XP. I have a php programming question. Hope you can help, because I can't test it in Apache. Having to test it live on my site. The ecard is sent successfully and, from what I can tell, all of the text is being sent, but the card image is not. Could you please take a gander at this? I checked with php.net about the mail() function requirements and thought I'd done it correctly, but apparently not. (The site is kieferart.com.)

Below is the pertinent code. I'm using sessions to load user input values from a previous page into the mail() function parameters. The contents of $_SESSION['imageName'] is loading correct values (e.g. certainImage.jpg) when viewing the source code on the page. Maybe I need to specify a particular path? Anyway, I'd really appreciate your help in this. It's sitting live on my website as we speak. Thank you.

greygrey

$to = 'To: ' . $_SESSION['rEmail'];
$subject = $_SESSION['sFirstName'] . ' ' . $_SESSION['sLastName'] . ' has sent you a Kieferart eCard!';
$message ="<html><head><title>Kieferart Ecards</title>\n
<style type='text/css'>\n
#ecardImage {position:absolute; top:175; left:325}\n
#ecardSalutation {position:absolute; top:360; left:330; font-family:Arial; text-align:left; color:black; font-size:9pt; font-weight:normal}\n
#ecardMessage {position:absolute; top:370; left:330; font-family:Arial; text-align:left; color:black; width:600; font-size:9pt; font-weight:normal}\n
#ecardClosing {position:absolute; top:670; left:315; font-family:Arial; text-align:left; color:black; font-size:9pt; font-weight:normal}\n
</style>
</head>
<body bgcolor='#000000' link='#000000' vlink='#ff00ff'>\n
<div id='ecardImage'>\n
<img src='" . $_SESSION[imageName] . "' width = '625' height='550' alt='" . $altName . "'>\n
</div>
<div id='ecardSalutation' align='left'>" . $_SESSION['salutation'] . "</div>\n
<div id='ecardMessage' align='left'>" .
$_SESSION['comments'] . "\n
<div id='ecardClosing' align='left'>" . $_SESSION['closing'] . "</div>\n";
$message = wordwrap($message, 70);
$headers = "From: " . $_SESSION['sEmail'] . "\r\n";
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
mail($to, $subject, $message, $headers);
?>
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7288
Location: Germany, Next to Hamburg

PostPosted: Sat 04 Dec '10 10:48    Post subject: Reply with quote

You have to save the image as a file onto the server and put the path to it into the mail

OR

you have to create a multipart email with image attached in base64 encoded.
Back to top
greygrey



Joined: 28 Mar 2008
Posts: 18

PostPosted: Sat 04 Dec '10 16:37    Post subject: Reply with quote

Thanks, James.

Ya know, I barely know what I'm doing as a developer. It's not my forte. I think I know in theory what you're talking about (saving the image as a file on the server), but I'm not sure how to go about that. Would it be something like this?

function upload()
{
$fileName = ($_FILES['file']['name']);
$target = "/home3/kieferar/public_html/uploads/";
$target = $target . basename($_FILES['file']['name']);
move_uploaded_file($_FILES['file']['tmp_name'], $target);
}

then extract it from the "/uploads" path?

As for your other suggestion, I don't have a clue how to do that. If you have time, could you please be a bit more specific about that?

greygrey
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7288
Location: Germany, Next to Hamburg

PostPosted: Sat 04 Dec '10 21:46    Post subject: Reply with quote

You already have the final filename in uploads in $target
Back to top


Reply to topic   Topic: php ecard program won't send card image View previous topic :: View next topic
Post new topic   Forum Index -> Coding & Scripting Corner