Add sending images

Hello! On page
very good, smart Contact Form. I tried to add to the form of the ability to attach an image PHPMayler library, but is suitable for this form, they are large and complex. What is the code for this form, a message is sent to the image no longer 1mb with extension .jpg, .png, .bmp? Thank you.

It’s not that good a script seeing as it uses get_magic_quotes_gpc() which is no longer used in PHP, and there’s a lot of code duplication.

Since the contact form doesn’t provide the facility to attach images we would need to see the code you’ve added for this.

  <form enctype="multipart/form-data" action="process.php" method="post">
    <input type="hidden" name="MAX_FILE_SIZE" value="1000000" />
    Choose a file to upload: <input name="attachimage" type="file" />
    <input type="submit" value="Upload" />


require 'class.phpmailer.php';

        if(isset($_FILES['attachimage'])) {
                 if($_FILES['attachimage']['error'] == 0){
                    if (!$mail->AddEmbeddedImage($_FILES['attachimage']['tmp_name'], 'my-attach', 'image.gif', 'base64', $_FILES['attachimage']['type']))
                         die ($mail->ErrorInfo);
                    $mess .= '<img src="cid:my-attach" border=0>';
        $mail->Body = $mess;

$email_body = 

if (isset($_REQUEST['comments']) && !$error_msg) {
mail ($your_email, $subject, $email_body, "From: $nam <$ema>" . "\r\n" . "Reply-To: $nam <$ema>" . "Content-Type: text/plain; charset=utf-8");

P.S. How to replace get_magic_quotes_gpc() ?

It looks as though you are adding another (separate) form and message sending function. That’s fine if that’s what you want but if you want to incorporate the two, you will need just one form and one message send (whether that is mail() or phpmailer). It’s going to be a bit of work to merge them.

As for get_magic_quotes_gpc() assuming you’re using PHP 5.4 or greater (which you should be) get_magic_quotes_gpc() will always be false. See the manual.

I tried to unite them , I did not succeed.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.