Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Upload images in contact form


Guest

Recommended Posts

Posted

Hello all, I've almost got this working from searching the forums but am really stumped at this point why it's not working. I simply need the customers to be able to attach an image that are sent to my email in the contact form. No database entry needed. Here's the link for my test site Contact Test Page

The email sends fine and everything works, but no attachment ever shows up.

 

Here's the code I added for the catalog/contact_us.php

 

require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_CONTACT_US);

 

$error = false;

if (isset($HTTP_GET_VARS['action']) && ($HTTP_GET_VARS['action'] == 'send')) {

$name = tep_db_prepare_input($HTTP_POST_VARS['name']);

$email_address = tep_db_prepare_input($HTTP_POST_VARS['email']);

$enquiry = tep_db_prepare_input($HTTP_POST_VARS['enquiry']);

if($_FILES['fileupload']['size'] > $HTTP_POST_FILES['MAX_FILE_SIZE']['value']){

echo '<div align="center" style="background:#FFFF00;">The file is to large. Please send a different file or edit it.</div>';

$error = true;

}

if (tep_validate_email($email_address)) {

tep_mail(STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, EMAIL_SUBJECT, $enquiry, $name, $email_address, $Attachment_filename, 'multipart/mixed');

 

<tr>

<td class="main"><?php echo ENTRY_EMAIL; ?></td>

</tr>

<tr>

<td class="main"><?php echo tep_draw_input_field('email'); ?></td>

</tr>

<tr>

<td class="main"><?php echo ENTRY_UPLOAD; ?></td>

</tr>

<tr>

<td class="main"><?php echo ENTRY_ENQUIRY; ?></td>

</tr>

<tr>

 

includes/languages/english/contact_us.php

 

define('ENTRY_UPLOAD', 'File Upload: (jpeg only format please.)<br><span><input type="file" size="40" name="fileupload" /></span>');

 

includes/function/general.php

 

function tep_mail($to_name, $to_email_address, $email_subject, $email_text, $from_email_name, $from_email_address, $attachment_file = false, $attachment_name = false, $attachment_type =false) {

if (SEND_EMAILS != 'true') return false;

 

// Instantiate a new mail object

$message = new email(array('X-Mailer: osCommerce Mailer'));

 

if ($attachment_file != false && $attachment_name != false && $attachment_type != false)

{

$attachments = $message->get_file($attachment_file);

$message->add_attachment($attachments, $attachment_name, $attachment_type);

}

 

Any help would be greatly appreciated. I really only need images to be sent so if anyone know how to set the format for jpeg and gif only that would be awesome!

  • 9 months later...
Posted

Hi, I'm very interested in this, Did you get to the final finish? I need something similar for a job. Could you put the solution? thank you very much from Spain. :rolleyes:

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...