UPDATE:
So after the success in uploading the file with the product attribute, I was looking at classes/shopping_cart.php and where it uses the upload class. I saw that it has "include(DIR_WS_CLASSES . 'upload.php');" so I put that into my code as well and I don't get a 500 error page now, the form successfully submits.
The attached file is not uploaded, and there's no attachment on the resulting email, but it redirects to an "?action=success" page and the email still sends with the rest of the form data. This is my code now:
Code:
<?php
/**
* Careers Application test page
*/
require(DIR_WS_MODULES . zen_get_module_directory('require_languages.php'));
include(DIR_WS_CLASSES . 'upload.php');
$error = false;
if (isset($_GET['action']) && ($_GET['action'] == 'send')) {
//Setting the input fields to php variables
$name = zen_db_prepare_input($_POST['name']);
$email_address = zen_db_prepare_input($_POST['email']);
$phone = zen_db_prepare_input($_POST['phone']);
$zip = zen_db_prepare_input($_POST['zip']);
$apply_attachment = new upload('attach');
$apply_attachment->set_destination(DIR_FS_UPLOADS);
$attachments_list = array();
$error_msg = '';
//checking if the value of the email field is valid with zencart func
$zc_validate_email = zen_validate_email($email_address);
//handle file upload/attachment
if ( $apply_attachment->parse() && $apply_attachment->save() ) {
if ($apply_attachment->filename != 'none') {
$attachments_list[] = $apply_attachment->file;
} else {
$error_msg = "Filename is empty or invalid.";
$error = true;
}
} else {
$error = true;
$error_msg = "You must successfully attach a file";
return false;
}
if ($zc_validate_email and !empty($name) and !empty($phone)) {
$send_to_email = "[address redacted]";
$send_to_name = "Robert Test";
// Prepare Text-only portion of message
$text_message = OFFICE_FROM . "\t" . $name . "\n" .
OFFICE_EMAIL . "\t" . $email_address . "\n\n" .
'------------------------------------------------------' . "\n\n" .
$name . "\n\n" . $email_address . "\n\n" . $phone . "\n\n" . $zip . "\n\n" .
'------------------------------------------------------' . "\n\n" .
// Prepare HTML-portion of message
$html_msg['EMAIL_MESSAGE_HTML'] = "Application submitted by: " . $name . "<br/><br/>"
. "Applicant Information:<br/><br/>"
. "Name: " . $name . "<br/>"
. "Email: " . $email_address . "<br/>"
. "Phone: " . $phone . "<br/>"
. "ZIP: " . $zip . "<br/><br/>";
$html_msg['CONTACT_US_OFFICE_FROM'] = OFFICE_FROM . ' ' . $name . '<br />' . OFFICE_EMAIL . '(' . $email_address . ')';
//$html_msg['EXTRA_INFO'] = $extra_info['HTML'];
// Send message
zen_mail($send_to_name, $send_to_email, 'Career Application Submitted', $text_message, $name, $email_address, $html_msg, 'default');
zen_redirect(zen_href_link(FILENAME_APPLY_TEST, 'action=success'));
} else {
$error = true;
if (empty($name)) {
$messageStack->add('contact', ENTRY_EMAIL_NAME_CHECK_ERROR);
}
if ($zc_validate_email == false) {
$messageStack->add('contact', ENTRY_EMAIL_ADDRESS_CHECK_ERROR);
}
if (empty($phone)) {
$messageStack->add('contact', ENTRY_EMAIL_CONTENT_CHECK_ERROR);
}
}
} // end action==send
// include template specific file name defines
$define_page = zen_get_file_directory(DIR_WS_LANGUAGES . $_SESSION['language'] . '/html_includes/', FILENAME_DEFINE_APPLY_TEST, 'false');
$breadcrumb->add(NAVBAR_TITLE);
?>
So it still looks pretty far from working since nothing about the file upload seems to be sticking, but it's not an error so maybe a step forward?
Bookmarks