Zappo, on Jul 4 2009, 02:11 PM, said:
Hello Rich.
-1: Thanx!
-2: The upload destination is set in application_top. This is done by checking for a registered session.
It's VERY strange the files end up in both! Does this happen when logged in (registered customer), as a guest, or both?!?
-3a: Please Note: crystalcopy.nl is NOT using Option Types v2!! (Basic functionality is the same however)
-3b: The text used in the cart is the same define as the text in product_info ("Option Name" is used, just like with other types)
I'm guessing something is wrong in application_top.php (case 'add_product' around Line: 370)
Have you merged with other contributions there?
Zappo, thanks for your quick response.
The files are saved correctly in their respective directory. There is no problem here at all.
Text input in product_info is also passed on to the cart correctly. No problem here either.
I understand that Option types functionality are basically the same but my problem is that I can't define upload-option values in admin's option value type because it has been taken off the drop down list of values available. So I guess it has to be defined somewhere for it to show up.
Yes, I did merged with other contributions, e.g QPBPP, SPPC
Here is my case 'add_product'
case 'add_product' : if (isset($HTTP_POST_VARS['products_id']) && is_numeric($HTTP_POST_VARS['products_id'])) {
//BOF - Zappo - Option Types v2 - File uploading: save uploaded files with unique file names, in the proper folder
$purgeDir = opendir(TMP_DIR) or die ('Could not open '.TMP_DIR);
while ($file = readdir($purgeDir)) {
if ($file != ('.htaccess') && filemtime(TMP_DIR . $file) < strtotime(OPTIONS_TYPE_PURGETIME)) {
unlink(TMP_DIR . $file); // Delete file from server...
tep_db_query("delete from " . TABLE_FILES_UPLOADED . " where files_uploaded_name = '" . $file . "'"); // Remove File's database entry....
}
}
closedir($purgeDir);
$real_ids = $HTTP_POST_VARS['id'];
if ($HTTP_POST_VARS['number_of_uploads'] > 0) {
require(DIR_WS_CLASSES . 'upload.php');
for ($i = 1; $i <= $HTTP_POST_VARS['number_of_uploads']; $i++) {
if (tep_not_null($_FILES['id']['tmp_name'][TEXT_PREFIX . $HTTP_POST_VARS[UPLOAD_PREFIX . $i]]) and ($_FILES['id']['tmp_name'][TEXT_PREFIX . $HTTP_POST_VARS[UPLOAD_PREFIX . $i]] != 'none')) {
$products_options_file = new upload('id');
//BOF - Zappo - Option Types v2 - Set Upload directory (Registered customers in Uploads, other in Temporary folder)
if (tep_session_is_registered('customer_id')) { // IF the customer is registered, use Upload Dir
$products_options_file->set_destination(UPL_DIR);
} else { // If the customer is not registered, use Temporary Dir
$products_options_file->set_destination(TMP_DIR);
}
//EOF - Zappo - Option Types v2 - Set Upload directory (Registered customers in Uploads, other in Temporary folder)
if ($products_options_file->parse(TEXT_PREFIX . $HTTP_POST_VARS[UPLOAD_PREFIX . $i])) {
if (tep_session_is_registered('customer_id')) {
tep_db_query("insert into " . TABLE_FILES_UPLOADED . " (sesskey, customers_id, files_uploaded_name, date) values('" . tep_session_id() . "', '" . $customer_id . "', '" . tep_db_input($products_options_file->filename) . "', '" . date("d-m-y") . "')");
} else {
tep_db_query("insert into " . TABLE_FILES_UPLOADED . " (sesskey, files_uploaded_name, date) values('" . tep_session_id() . "', '" . tep_db_input($products_options_file->filename) . "', '" . date("d-m-y") . "')");
}
//BOF - Zappo - Option Types v2 - Set File Prefix
if (OPTIONS_TYPE_FILEPREFIX == 'Database') { // Database ID as File prefix
$insert_id = tep_db_insert_id() . '_';
} else { // Date, time or both as File prefix (Change date formatting here)
if (OPTIONS_TYPE_FILEPREFIX == 'Date' || OPTIONS_TYPE_FILEPREFIX == 'DateTime') {
$insert_id = 'D'.date("d-m-y_");
}
$insert_id .= (OPTIONS_TYPE_FILEPREFIX == 'DateTime' || OPTIONS_TYPE_FILEPREFIX == 'Time') ? 'T'.date("H-i_") : '';
}
//EOF - Zappo - Option Types v2 - Set File Prefix
// Update filename in Database with correct prefix (For comparing database names with real files)
tep_db_query("update " . TABLE_FILES_UPLOADED . " set files_uploaded_name = '" . tep_db_input($insert_id . $products_options_file->filename) . "' where sesskey = '" . tep_session_id() . "' and files_uploaded_name = '" . tep_db_input($products_options_file->filename) . "' and date = '" . date("d-m-y") . "'");
$real_ids[TEXT_PREFIX . $HTTP_POST_VARS[UPLOAD_PREFIX . $i]] = $insert_id . $products_options_file->filename;
$products_options_file->set_filename($insert_id . $products_options_file->filename);
if (!($products_options_file->save())) {
break 2;
}
} else {
break 2;
}
} else { // No file uploaded -- use previously uploaded file
$real_ids[TEXT_PREFIX . $HTTP_POST_VARS[UPLOAD_PREFIX . $i]] = $HTTP_POST_VARS[TEXT_PREFIX . UPLOAD_PREFIX . $i];
}
}
}
//EOF - Zappo - Option Types v2 - File uploading: save uploaded files with unique file names, in the proper folder
// BOF QPBPP for SPPC
$cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $HTTP_POST_VARS['id'])) + $HTTP_POST_VARS['cart_quantity'], $HTTP_POST_VARS['id']);
// EOF QPBPP for SPPC
}
tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
break;
Is this ok? or would you rather I post the whole application_top.php
Thanks again.
Rich