Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

need for customer to email a logo


wyzzkid

Recommended Posts

Posted

hi,

 

I have a simple form page for a customer to fill in (based on the ask-a-question contribution); in this case, I need for the customer to be able to attach a logo and submit that, and to be sent by email

 

I have tried a number of combinations, but cant get the file attached (after searching the site, the closest thing I found was an unanswered question from 2002)

 

the first part of the form is simple:

			<td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
		  <tr class="infoBoxContents">
			<td><table border="0" cellspacing="0" cellpadding="2">
			  <tr>
				<td class="main"><?php echo FORM_FIELD_CUSTOMER_NAME; ?></td>
				<td class="main"><?php echo tep_draw_input_field('from_name', $from_name); ?><span class="inputRequirement">*</span></td>  
			  </tr>
			  <tr>
				<td class="main"><?php echo FORM_FIELD_CUSTOMER_EMAIL; ?></td>
				<td class="main"><?php echo tep_draw_input_field('from_email_address', $from_email_address); ?><span class="inputRequirement">*</span></td>
			  </tr>
			  <tr>
				<td class="main"><?php echo FORM_FIELD_FILE_ATTACH; ?></td>
				<td class="main"><?php echo tep_draw_input_field('attachment[]','','size="30"','file'); ?> </td>
			  </tr>
			</table></td>

 

what I dont know is: do I need 'attachment' or 'attachment[]' in the last field ?

if it is an array, what fields are in there?

 

I copied the following from the contribution, and added the line for the attachment:

  if (isset($HTTP_GET_VARS['action']) && ($HTTP_GET_VARS['action'] == 'process')) {
$error = false;

$to_email_address = tep_db_prepare_input($HTTP_POST_VARS['to_email_address']);
$to_name = tep_db_prepare_input($HTTP_POST_VARS['to_name']);
$from_email_address = tep_db_prepare_input($HTTP_POST_VARS['from_email_address']);
$from_name = tep_db_prepare_input($HTTP_POST_VARS['from_name']);
$message = tep_db_prepare_input($HTTP_POST_VARS['message']);
// adding attachment 
$attachment = tep_db_prepare_input($HTTP_POST_VARS['attachment']);

 

finally, I looked at tep_mail() which does not include a parameter for attachements, so I tried copying it and adding a line just before the the send:

 

  function logo_tep_mail($to_name, $to_email_address, $email_subject, $email_text, $from_email_name, $from_email_address, $attachment) {
if (SEND_EMAILS != 'true') return false;

// Instantiate a new mail object
$message = new email(array('X-Mailer: osCommerce'));

// Build the text version
$text = strip_tags($email_text);
if (EMAIL_USE_HTML == 'true') {
  $message->add_html($email_text, $text);
} else {
  $message->add_text($text);
}

//   add the attachment
$message->add_attachment( $message->get_file($attachment[name]), $attachment[name] );
// I tried with $attachment, $attachment[] and a variety of others
// I did find this example line somewhere, but did not know how to make it work:  $_FILES['attachment']['tmp_name'][$i],$_FILES['attachment']['name'][$i]

// Send message
$message->build_message();
$message->send($to_name, $to_email_address, $from_email_name, $from_email_address, $email_subject);
 }

 

so the questions are:

did I set the form field right to grab the customers logo?

how do I attach the thing in the email ?

if there is a need to add another logo (or other attachment) later, will that make a difference?

 

thanx very much in advance :)

Posted

ok, so after experimenting tons, I learned a few things, but still need some help;

 

in the form, I use:

<td class="main"><?php echo tep_draw_input_field('attachment[]','','size="30"','file'); ?> </td>

with empty [] brackets

and use [0] get the full path to the filename

 

but when I try to attach the file, there error is that the file can not be found; (obviosly looking on the server, and not the customer machine; so, the question is:

how do I upload the file (I can create a folder, but am I better off with /logos or /images/logos)

 

is there a way to upload it only long enough to send the email, then remove it, or should I manually clear the folder?, and if so, is there a way of changing the filename, with either the timestamp or customer name attached (to prevent name collision, like two people sending logo.jpg) ?

 

any help will be greatly appreciated :)

Archived

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

×
×
  • Create New...