zpeedfreak Posted February 22, 2005 Share Posted February 22, 2005 I was just wondering if anyone knew of an existing contribution that would allow registered customers to upload files (images). I was wondering because I have a client who wants has a digitizing service and she wants her clients to be able to upload their logos and other art work to her to evaluate how much she will charge to digitize. And then the client will login to their account and download the special digitized file zipped to bring to their embroider of choice. Link to comment Share on other sites More sharing options...
John Doswell Posted February 22, 2005 Share Posted February 22, 2005 I was just wondering if anyone knew of an existing contribution that would allow registered customers to upload files (images). I was wondering because I have a client who wants has a digitizing service and she wants her clients to be able to upload their logos and other art work to her to evaluate how much she will charge to digitize. And then the client will login to their account and download the special digitized file zipped to bring to their embroider of choice. <{POST_SNAPBACK}> there ar a lot of scripts down at www.hotscripts.com just add if (!tep_session_is_registered('customer_id')) { $navigation->set_snapshot(); tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL')); } at the top of the file and only registered useres can use it ;-) greetz john Link to comment Share on other sites More sharing options...
cannuck1964 Posted February 22, 2005 Share Posted February 22, 2005 $allowed_files_types = array('gif', 'jpg', 'png'); $newname = DIR_FS_CATALOG .'images/'; // copy image $store_logo_image = new upload('store_image'); $store_logo_image->set_destination($newname); $store_logo_image->set_extensions($allowed_files_types); $parsed = $store_logo_image->parse(); $ext = (substr($store_logo_image->filename, -4)); $store_logo_image->set_filename('logo' . $ext); $saved = $store_logo_image->save(); if ($parsed && $saved){ $store_logo_image_name = $store_logo_image->filename; }else{ $store_logo_image_name = ''; } do not forget to copy the admin/includes/classes/upload.php to the folder catalog/includes/classes/upload.php this should give you the basics for the code..... for the input field, you need to copy the function tep_draw_file_field () from the file admin/includes/functions/html_output.php and put it into the file catelog/includes/functions/html_output.php add add in something like <tr> <td class="main"><?php echo TEXT_STORES_IMAGE; ?></td> <td class="main"><?php echo tep_draw_file_field('store_image'). ' <br>' .(tep_not_null(ENTRY_LOGO_TEXT) ? '<span class="inputRequirement">' . ENTRY_LOGO_TEXT . '</span>': ''); ?></td> </tr> to display the input field on the page, last you need to have in the POSTed FORM the following 'enctype="multipart/form-data" cheers and HTH Peter M. Peter McGrath ----------------------------- See my Profile (click here) for more information and to contact me for professional osCommerce support that includes SEO development, custom development and security implementation Link to comment Share on other sites More sharing options...
zpeedfreak Posted February 22, 2005 Author Share Posted February 22, 2005 Thanks for your help. I'll experiment with that code Peter. Link to comment Share on other sites More sharing options...
valley Posted July 9, 2005 Share Posted July 9, 2005 Hello Peter, I am trying to use your suggestions to incorporate an Image UPLOAD feature in the product_reviews_write.php. The basic idea is that while customers are reticent to write any thing about a product let alone good things, they are keen to put their pictures with their new products. However I can't get the Browse button to appear near the field. as you can see from My Webpage I have followed your instructions and here is the modified code I have <?php /* $Id: product_reviews_write.php,v 1.51 2003/02/13 04:23:23 hpdl Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2003 osCommerce Released under the GNU General Public License */ require('includes/application_top.php'); if (!tep_session_is_registered('customer_id')) { $navigation->set_snapshot(); tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL')); } $allowed_files_types = array('gif', 'jpg', 'png'); $newname = DIR_FS_CATALOG .'images/'; // copy image $store_logo_image = new upload('store_image'); $store_logo_image->set_destination($newname); $store_logo_image->set_extensions($allowed_files_types); $parsed = $store_logo_image->parse(); $ext = (substr($store_logo_image->filename, -4)); $store_logo_image->set_filename('logo' . $ext); $saved = $store_logo_image->save(); if ($parsed && $saved){ $store_logo_image_name = $store_logo_image->filename; }else{ $store_logo_image_name = ''; } $product_query = tep_db_query("select pd.products_name, p.products_image from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . $languages_id . "' and p.products_status = '1'"); $valid_product = (tep_db_num_rows($product_query) > 0); if (isset($HTTP_GET_VARS['action']) && $HTTP_GET_VARS['action'] == 'process') { if ($valid_product == true) { // We got to the process but it is an illegal product, don't write $customer = tep_db_query("select customers_firstname, customers_lastname from " . TABLE_CUSTOMERS . " where customers_id = '" . $customer_id . "'"); $customer_values = tep_db_fetch_array($customer); $date_now = date('Ymd'); tep_db_query("insert into " . TABLE_REVIEWS . " (products_id, customers_id, customers_name, reviews_rating, date_added) values ('" . $HTTP_GET_VARS['products_id'] . "', '" . $customer_id . "', '" . addslashes($customer_values['customers_firstname']) . ' ' . addslashes($customer_values['customers_lastname']) . "', '" . $HTTP_POST_VARS['rating'] . "', now())"); $insert_id = tep_db_insert_id(); tep_db_query("insert into " . TABLE_REVIEWS_DESCRIPTION . " (reviews_id, languages_id, reviews_text) values ('" . $insert_id . "', '" . $languages_id . "', '" . $HTTP_POST_VARS['review'] . "')"); } tep_redirect(tep_href_link(FILENAME_PRODUCT_REVIEWS, $HTTP_POST_VARS['get_params'])); } // lets retrieve all $HTTP_GET_VARS keys and values.. $get_params = tep_get_all_get_params(); $get_params_back = tep_get_all_get_params(array('reviews_id')); // for back button $get_params = substr($get_params, 0, -1); //remove trailing & if (tep_not_null($get_params_back)) { $get_params_back = substr($get_params_back, 0, -1); //remove trailing & } else { $get_params_back = $get_params; } require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_PRODUCT_REVIEWS_WRITE); $breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_PRODUCT_REVIEWS, $get_params)); $customer_info_query = tep_db_query("select customers_firstname, customers_lastname from " . TABLE_CUSTOMERS . " where customers_id = '" . $customer_id . "'"); $customer_info = tep_db_fetch_array($customer_info_query); ?> <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"> <html <?php echo HTML_PARAMS; ?>> <head> <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>"> <?php // BOF: WebMakers.com Changed: Header Tag Controller v1.0 // Replaced by header_tags.php if ( file_exists(DIR_WS_INCLUDES . 'header_tags.php') ) { require(DIR_WS_INCLUDES . 'header_tags.php'); } else { ?> <title><?php echo TITLE ?></title> <?php } // EOF: WebMakers.com Changed: Header Tag Controller v1.0 ?> <base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>"> <link rel="stylesheet" type="text/css" href="stylesheet.css"> <script language="javascript"><!-- function checkForm() { var error = 0; var error_message = "<?php echo JS_ERROR; ?>"; var review = document.product_reviews_write.review.value; if (review.length < <?php echo REVIEW_TEXT_MIN_LENGTH; ?>) { error_message = error_message + "<?php echo JS_REVIEW_TEXT; ?>"; error = 1; } if ((document.product_reviews_write.rating[0].checked) || (document.product_reviews_write.rating[1].checked) || (document.product_reviews_write.rating[2].checked) || (document.product_reviews_write.rating[3].checked) || (document.product_reviews_write.rating[4].checked)) { } else { error_message = error_message + "<?php echo JS_REVIEW_RATING; ?>"; error = 1; } if (error == 1) { alert(error_message); return false; } else { return true; } } //--></script> <script LANGUAGE="JavaScript1.2" SRC="includes/menu_animation.js"></SCRIPT> </head> <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0"> <!-- coolMenu //--> <?php require(DIR_WS_INCLUDES . 'coolmenu.php'); ?> <!-- coolMenu_eof //--> <!-- header //--> <?php require(DIR_WS_INCLUDES . 'header.php'); ?> <!-- header_eof //--> <!-- body //--> <table border="0" width="100%" cellspacing="3" cellpadding="3"> <tr> <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2"> <!-- left_navigation //--> <?php require(DIR_WS_INCLUDES . 'column_left.php'); ?> <!-- left_navigation_eof //--> </table></td> <!-- body_text //--> <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td><table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td class="pageHeading"><?php echo HEADING_TITLE; ?></td> <td class="pageHeading" align="right"><?php echo tep_image(DIR_WS_IMAGES . 'table_background_reviews.gif', HEADING_TITLE, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td> </tr> </table></td> </tr> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> </tr> <?php if ($valid_product == false) { ?> <tr> <td class="main"><br><b><?php echo ERROR_INVALID_PRODUCT; ?></b></td> </tr> <?php } else { $product_info = tep_db_fetch_array($product_query); ?> <tr> <td><table border="0" width="100%" cellspacing="0" cellpadding="0"> <?php echo tep_draw_form('product_reviews_write', tep_href_link(FILENAME_PRODUCT_REVIEWS_WRITE, 'action=process&products_id=' . $HTTP_GET_VARS['products_id']), 'post', 'onSubmit="return checkForm();"'); ?> <tr> <td class="main"><b><?php echo SUB_TITLE_PRODUCT; ?></b> <?php echo $product_info['products_name']; ?></td> <td rowspan="4" valign="top" align="right"><br><?php echo tep_image(DIR_WS_IMAGES . $product_info['products_image'], $product_info['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'hspace="5" vspace="5"'); ?></td> </tr> <tr> <td class="main"><b><?php echo SUB_TITLE_FROM; ?></b> <?php echo $customer_info['customers_firstname'] . ' ' . $customer_info['customers_lastname']; ?></td> </tr> <tr> <td class="main"><br><b><?php echo SUB_TITLE_REVIEW; ?></b></td> </tr> <tr> <td><?php echo tep_draw_textarea_field('review', 'soft', 60, 15);?></td> </tr> <tr> <td class="smallText"><?php echo TEXT_NO_HTML; ?></td> </tr> </table></td> </tr> <tr> <td class="main"><br><b><?php echo SUB_TITLE_RATING; ?></b> <?php echo TEXT_BAD . ' ' . tep_draw_radio_field('rating', '1') . ' ' . tep_draw_radio_field('rating', '2') . ' ' . tep_draw_radio_field('rating', '3') . ' ' . tep_draw_radio_field('rating', '4') . ' ' . tep_draw_radio_field('rating', '5') . ' ' . TEXT_GOOD; ?></td> </tr> <!-- <tr> <td class="main"><?php echo TEXT_PRODUCTS_IMAGE; ?></td> <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_file_field('products_image') . '<br>' . tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . $pInfo->products_image . tep_draw_hidden_field('products_previous_image', $pInfo->products_image); ?></td> </tr> --> <tr> <td class="main"><br><table border="0" width="100%" cellspacing="0" cellpadding="2"> <tr> <td class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_REVIEWS, $get_params_back) . '">' . tep_image_button('button_back.gif', IMAGE_BUTTON_BACK) . '</a>'; ?></td> <td align="right" class="main"><?php echo tep_image_submit('button_continue.gif', IMAGE_BUTTON_CONTINUE); ?></td> </tr> </table><?php echo tep_draw_hidden_field('get_params', $get_params); ?></form></td> </tr> <?php } ?> <tr> <td class="main"><?php echo TEXT_STORES_IMAGE; ?></td> <td class="main"><?php echo tep_draw_file_field('store_image'). ' <br>' .(tep_not_null(ENTRY_LOGO_TEXT) ? '<span class="inputRequirement">' . ENTRY_LOGO_TEXT . '</span>': ''); ?></td> </tr> <br /> </table></td> <!-- body_text_eof //--> <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2"> <!-- right_navigation //--> <?php require(DIR_WS_INCLUDES . 'column_right.php'); ?> <!-- right_navigation_eof //--> </table></td> </tr> </table> <!-- body_eof //--> <!-- footer //--> <?php require(DIR_WS_INCLUDES . 'footer.php'); ?> <!-- footer_eof //--> <br> </body> </html> <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?> As you can see I use the catalog image directory and haven't changed the code for the time being to reflect the context of the review page. Wonder if you could take a look and suggest how to get this working. Link to comment Share on other sites More sharing options...
cannuck1964 Posted July 9, 2005 Share Posted July 9, 2005 Hi, One issue I see right away is this code <?php echo tep_draw_form('product_reviews_write', tep_href_link(FILENAME_PRODUCT_REVIEWS_WRITE, 'action=process&products_id=' . $HTTP_GET_VARS['products_id']), 'post', 'onSubmit="return checkForm();"'); ?> needs to be changed to something like this... ? ? ? ? <?php echo tep_draw_form('product_reviews_write', tep_href_link(FILENAME_PRODUCT_REVIEWS_WRITE, 'action=process&products_id=' . $HTTP_GET_VARS['products_id']), 'post', 'enctype="multipart/form-data" onSubmit="return checkForm();"'); ?> This may need to be adjusted a bit, but basically you need to let the system know that the form may be getting a file when you add 'enctype="multipart/form-data" to the form declaration..... Make sure you copied the function as outlined before..... cheers, Peter M. Peter McGrath ----------------------------- See my Profile (click here) for more information and to contact me for professional osCommerce support that includes SEO development, custom development and security implementation Link to comment Share on other sites More sharing options...
valley Posted July 10, 2005 Share Posted July 10, 2005 Hi, One issue I see right away is this code <?php echo tep_draw_form('product_reviews_write', tep_href_link(FILENAME_PRODUCT_REVIEWS_WRITE, 'action=process&products_id=' . $HTTP_GET_VARS['products_id']), 'post', 'onSubmit="return checkForm();"'); ?> needs to be changed to something like this... ? ? ? ? <?php echo tep_draw_form('product_reviews_write', tep_href_link(FILENAME_PRODUCT_REVIEWS_WRITE, 'action=process&products_id=' . $HTTP_GET_VARS['products_id']), 'post', 'enctype="multipart/form-data" onSubmit="return checkForm();"'); ?> This may need to be adjusted a bit, but basically you need to let the system know that the form may be getting a file when you add 'enctype="multipart/form-data" to the form declaration..... Make sure you copied the function as outlined before..... cheers, Peter M. <{POST_SNAPBACK}> Hello Peter Ihave done the above and also checked the function . I have also moved the code to be within the FORM as it was outside. I have infact added the DRAW_HIDDEN_FIELD to the call in line with the code segment from the admin/catogory.php where it works (code section commented out) <tr> <td class="main"><br><b><?php echo SUB_TITLE_RATING; ?></b> <?php echo TEXT_BAD . ' ' . tep_draw_radio_field('rating', '1') . ' ' . tep_draw_radio_field('rating', '2') . ' ' . tep_draw_radio_field('rating', '3') . ' ' . tep_draw_radio_field('rating', '4') . ' ' . tep_draw_radio_field('rating', '5') . ' ' . TEXT_GOOD; ?></td> </tr> <!-- <tr> <td class="main"><?php echo TEXT_STORES_IMAGE; ?></td> <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_file_field('store_image') . '<br>' . tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . $saved . tep_draw_hidden_field('$store_logo_image_name', $saved); ?></td> </tr> --> <tr> <td class="main"><?php echo TEXT_STORES_IMAGE; ?></td> <td class="main"><?php echo tep_draw_file_field('store_image'). ' <br>' .(tep_not_null(ENTRY_LOGO_TEXT) ? '<span class="inputRequirement">' . ENTRY_LOGO_TEXT . '</span>': ''); ?></td> </tr> <tr> <td class="main"><br><table border="0" width="100%" cellspacing="0" cellpadding="2"> <tr> <td class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_REVIEWS, $get_params_back) . '">' . tep_image_button('button_back.gif', IMAGE_BUTTON_BACK) . '</a>'. tep_draw_hidden_field('$store_logo_image_name', $saved); ?></td> <td align="right" class="main"><?php echo tep_image_submit('button_continue.gif', IMAGE_BUTTON_CONTINUE); ?></td> </tr> </table><?php echo tep_draw_hidden_field('get_params', $get_params); ?></form></td> </tr> <?php } ?> Here is the view I still can't get the Bowse Button Link to comment Share on other sites More sharing options...
swacks Posted July 22, 2005 Share Posted July 22, 2005 Hello Peter Ihave done the above and also checked the function . I have also moved the code to be within the FORM as it was outside. I have infact added the DRAW_HIDDEN_FIELD to the call in line with the code segment from the admin/catogory.php where it works (code section commented out) <tr> ? ? ? ?<td class="main"><br><b><?php echo SUB_TITLE_RATING; ?></b> <?php echo TEXT_BAD . ' ' . tep_draw_radio_field('rating', '1') . ' ' . tep_draw_radio_field('rating', '2') . ' ' . tep_draw_radio_field('rating', '3') . ' ' . tep_draw_radio_field('rating', '4') . ' ' . tep_draw_radio_field('rating', '5') . ' ' . TEXT_GOOD; ?></td> ? ? ?</tr> ? ? ?<!-- <tr> ? ? ? ? ? ?<td class="main"><?php echo TEXT_STORES_IMAGE; ?></td> ? ? ? ? ? ?<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_file_field('store_image') . '<br>' . tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . $saved . tep_draw_hidden_field('$store_logo_image_name', ?$saved); ?></td> ? ? ? ? ?</tr> --> ? ? ?<tr> ? ?<td class="main"><?php echo TEXT_STORES_IMAGE; ?></td> ? ?<td class="main"><?php echo ?tep_draw_file_field('store_image'). ' <br>' .(tep_not_null(ENTRY_LOGO_TEXT) ? '<span class="inputRequirement">' . ENTRY_LOGO_TEXT . '</span>': ''); ?></td> ? ?</tr> ? ? ?<tr> ? ? ? ?<td class="main"><br><table border="0" width="100%" cellspacing="0" cellpadding="2"> ? ? ? ? ?<tr> ? ? ? ? ? ?<td class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_REVIEWS, $get_params_back) . '">' . tep_image_button('button_back.gif', IMAGE_BUTTON_BACK) . '</a>'. tep_draw_hidden_field('$store_logo_image_name', ?$saved); ?></td> ? ? ? ? ? ?<td align="right" class="main"><?php echo tep_image_submit('button_continue.gif', IMAGE_BUTTON_CONTINUE); ?></td> ? ? ? ? ?</tr> ? ? ? ?</table><?php echo tep_draw_hidden_field('get_params', $get_params); ?></form></td> ? ? ?</tr> <?php ?} ?> Here is the view I still can't get the Bowse Button <{POST_SNAPBACK}> I am wondering if you cam right with customer image upload as I would also like to use this feature. BTW your site is probably the most stunning oscommerce site I have seen Thank you kindly Selwyn Selwyn Wacks Link to comment Share on other sites More sharing options...
valley Posted October 8, 2005 Share Posted October 8, 2005 I am wondering if you cam right with customer image upload as I would also like to use this feature. BTW your site is probably the most stunning oscommerce site I have seen Thank you kindly Selwyn Thank you Selwyn for your kind remarks about my OSC site. Unfortunately I couldn't find a correction to the code to get it working yet. I hope Peter or any of the Gurus of OSC will help to get the code right and publish this as a contribution. It will be much appreciated. Link to comment Share on other sites More sharing options...
valley Posted October 9, 2005 Share Posted October 9, 2005 Thank you Selwyn for your kind remarks about my OSC site.Unfortunately I couldn't find a correction to the code to get it working yet. I hope Peter or any of the Gurus of OSC will help to get the code right and publish this as a contribution. It will be much appreciated. After some digging in to the admin catogories.php, I realise that I need to add a field in the table TABLE_REVIEWS_DESCRIPTION to save the uploaded image in and add the routine to do this. Is there a way to modify the code segment of Peter posted above to copy the image to do this ? Link to comment Share on other sites More sharing options...
valley Posted October 10, 2005 Share Posted October 10, 2005 After some digging in to the admin catogories.php, I realise that I need to adda field in the table TABLE_REVIEWS_DESCRIPTION to save the uploaded image in and add the routine to do this. Is there a way to modify the code segment of Peter posted above to copy the image to do this ? By using a script (simple-upload-53.php) available from Hotscripts.com as an INCLUDE file, I could get a file upload feature within the review write page. It is now required to save the Image in the database ,perhaps by modifying the product_review_write.php querry tep_db_query("insert into " . TABLE_REVIEWS_DESCRIPTION . " (reviews_id, languages_id, reviews_text) values ('" . $insert_id . "', '" . $languages_id . "', '" . $HTTP_POST_VARS['review'] . "')"); and modifying the product_review_info.php to retrive it and present it with the reviews. $reviews_query = tep_db_query("select rd.reviews_text, r.reviews_rating, r.reviews_id, r.products_id, r.customers_name, r.date_added, r.last_modified, r.reviews_read, p.products_id, pd.products_name, p.products_image from " . TABLE_REVIEWS . " r, " . TABLE_REVIEWS_DESCRIPTION . " rd left join " . TABLE_PRODUCTS . " p on (r.products_id = p.products_id) left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on (p.products_id = pd.products_id and pd.language_id = '". $languages_id . "') where r.reviews_id = '" . (int)$HTTP_GET_VARS['reviews_id'] . "' and r.reviews_id = rd.reviews_id and p.products_status = '1'"); if (!tep_db_num_rows($reviews_query)) tep_redirect(tep_href_link(FILENAME_REVIEWS)); $reviews = tep_db_fetch_array($reviews_query); I presume it can then be called like a thumb nail in to the review page using something similar to <td class="smallText" rowspan="3" align="center"><a href="javascript:popupImageWindow('<?php echo tep_href_link(FILENAME_POPUP_IMAGE, 'pID=' . $reviews['products_id']); ?>')"><?php echo tep_image(DIR_WS_IMAGES . $reviews['products_image'], $reviews['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'align="center" hspace="5" vspace="5"'); ?><br></a></td> I am no way a php coder and am not sure about how this can be achieved. Can anyone please help ? Please PM me if you need more info Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.