Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Extra Images Contribution Advancement


Recommended Posts

I have been developing an advanced version of the Extra Images Contribution. It allows the store owner to browse & upload extra images for any product via the admin area. While in development I am working on it in the products_extra_images.php file. The long term goal is to merge it with the product creation/modification page (categories.php).

 

Anyway...I don't claim to be a PHP expert, but I know enough to get around. I need a little help with this code. Everything seems to work and gets written to the database perfectly, but the file that is selected does not actually upload to the images directory. Can someone please tell me why the upload isn't working? THANKS!!

 

<?php
/*
 $Id: products_extra_images.php,v 1.0 2003/06/11 Mikel Williams
 
 Advancements made by Aaron Hiatt 2005

 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');

// check if the catalog image directory exists
 if (is_dir(DIR_FS_CATALOG_IMAGES)) {
   if (!is_writeable(DIR_FS_CATALOG_IMAGES)) $messageStack->add(ERROR_CATALOG_IMAGE_DIRECTORY_NOT_WRITEABLE, 'error');
 } else {
   $messageStack->add(ERROR_CATALOG_IMAGE_DIRECTORY_DOES_NOT_EXIST, 'error');
 }
//BOF - Custom Hack for Extra Product Images Admin Interface //////////////////////////////////////////////	
 if ($HTTP_GET_VARS['action']) {
   switch ($HTTP_GET_VARS['action']) {
	 case 'update_extra_images':
	 $sql_data_array = array('products_extra_images_id' => tep_db_prepare_input($HTTP_POST_VARS['products_extra_images_id']),
                          'products_extra_image' => tep_db_prepare_input($HTTP_POST_VARS['products_extra_image']),
      	 'products_id' => tep_db_prepare_input($HTTP_POST_VARS['products_id']));

   
	 tep_db_perform(TABLE_PRODUCTS_EXTRA_IMAGES, $sql_data_array, 'update', 'products_extra_images_id=' . tep_db_input($products_extra_images_id));
   
   tep_redirect(tep_href_link(FILENAME_PRODUCTS_EXTRA_IMAGES));
	 break;

	 case 'add_extra_images':
   $sql_data_array = array('products_extra_image' => tep_db_prepare_input($HTTP_POST_VARS['products_extra_image']),
                           'products_id' => tep_db_prepare_input($HTTP_POST_VARS['products_id']));
	 

   
  	 tep_db_perform(TABLE_PRODUCTS_EXTRA_IMAGES, $sql_data_array, 'insert');
	 
	 tep_redirect(tep_href_link(FILENAME_PRODUCTS_EXTRA_IMAGES));
	 break;

	 case 'delete_extra_images':
	 $sql_data_array = array('products_extra_images_id' => tep_db_prepare_input($HTTP_POST_VARS['products_extra_images_id']));
   tep_db_query("DELETE FROM " . TABLE_PRODUCTS_EXTRA_IMAGES . " WHERE products_extra_images_id=" . tep_db_input($products_extra_images_id));
   tep_redirect(tep_href_link(FILENAME_PRODUCTS_EXTRA_IMAGES));
	 break;
 }
}

$products_array = array(array('id' => '', 'text' => TEXT_NONE));
$products_query = tep_db_query("select p.products_id, p.products_model, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = pd.products_id order by products_model");
while ($products = tep_db_fetch_array($products_query)) {
 $products_array[] = array('id' => $products['products_id'],
         'text' => $products['products_name']);
}
//EOF - Custom Hack for Extra Product Images Admin Interface //////////////////////////////////////////////
?>
<!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; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
<script language="javascript" src="includes/general.js"></script>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onload="SetFocus();">
<div id="spiffycalendar" class="text"></div>
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->

<!-- body //-->
<table border="0" width="100%" cellspacing="2" cellpadding="2">
 <tr>
   <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">
<!-- 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 width="100%">
  <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_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
         </tr>
       </table>
   </td>
     </tr>
<TR>
 <TD width="100%" valign="top">  
	 <table width="100%" cellspacing="1" cellpadding="3">
 <tr class="dataTableHeadingRow">
   <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_PRODUCTS_ID; ?></td>
   <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_PRODUCTS_MODEL; ?></td>
   <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_PRODUCTS_IMAGE; ?></td>
<td class="dataTableHeadingContent"> </td>
 </tr>
 <?php 
//BOF - Custom Hack for Extra Product Images Admin Interface //////////////////////////////////////////////
 $products_extra_images_query = tep_db_query("SELECT pei.products_extra_image, pei.products_extra_images_id, pei.products_id, p.products_model FROM " . TABLE_PRODUCTS_EXTRA_IMAGES . " pei LEFT JOIN " . TABLE_PRODUCTS . " p ON pei.products_id = p.products_id order by p.products_model");
	 while ($extra_images = tep_db_fetch_array($products_extra_images_query)) {
?>
 <tr bgcolor=<?php echo $rowcolor; ?>>
 <?php echo tep_draw_form('extra_images_' . $extra_images['update_extra_images_id'], FILENAME_PRODUCTS_EXTRA_IMAGES, 'action=update_extra_images'); ?>
 <?php echo tep_draw_hidden_field('products_extra_images_id',$extra_images['products_extra_images_id']); ?>
   <td class="dataTableContent"><?php echo $extra_images['products_id'] ?></td>
   <td class="dataTableContent"><?php echo tep_draw_pull_down_menu('products_id', $products_array, $extra_images['products_id']); ?></td>	

<!--
<td class="dataTableContent"><?php echo tep_draw_input_field('products_extra_image',$extra_images['products_extra_image'],'size=50 value=' . $extra_images['products_extra_image']); ?></td>
-->

<td class="dataTableContent">
<?php echo tep_draw_file_field('products_extra_image') . '<br>Currently: ' . $extra_images['products_extra_image'] . tep_draw_hidden_field('products_previous_image', $extra_images['products_extra_image']); ?></td>

   <td class="dataTableContent">
<?php echo tep_image_submit('button_save.gif', IMAGE_SAVE); ?>
</form>
<?php echo tep_draw_form('extra_images_' . $extra_images['delete_extra_images_id'], FILENAME_PRODUCTS_EXTRA_IMAGES, 'action=delete_extra_images'); ?>
<?php echo tep_draw_hidden_field('products_extra_images_id',$extra_images['products_extra_images_id']); ?>
<?php echo tep_image_submit('button_delete.gif', IMAGE_DELETE); ?>
</form>
</td>
 </tr>
<?php
if ($rowcolor=='EEEEEE'){$rowcolor='FFFFFF';}
else {$rowcolor='EEEEEE';}
}
?>
 <tr bgcolor=<?php echo $rowcolor; ?>>
   <?php echo tep_draw_form('extra_images_' . $extra_images['add__extra_images'], FILENAME_PRODUCTS_EXTRA_IMAGES, 'action=add_extra_images'); ?>
<td class="dataTableContent"> </td>
   <td class="dataTableContent"><?php echo tep_draw_pull_down_menu('products_id', $products_array, $pInfo->products_id); ?></td>

<!--
   <td class="dataTableContent"><?php echo tep_draw_input_field('products_extra_image',$extra_images['products_extra_image'],'size=50'); ?></td>
-->

<td class="dataTableContent">
<?php echo tep_draw_file_field('products_extra_image') . tep_draw_hidden_field('products_previous_image', $extra_images['products_extra_image']); ?></td>

   <td class="dataTableContent"><?php echo tep_image_submit('button_save.gif', IMAGE_SAVE); ?></td>
</form>
 </tr>
 <tr>
   <td colspan="5"><br></td>
 </tr>
</table>
 </td>
<!-- body_text_eof //-->
 </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'); ?>

Link to comment
Share on other sites

Hi Aaron,

 

Long time since we touched base ....

 

I've been banging my head also with the image upload in the past.

Wasn't it on some poll code with images ?

 

Anyhow, the admin/manufacturers.php page is fairly simple and includes an image upload.

 

The key sample code in there:

         if ($manufacturers_image = new upload('manufacturers_image', DIR_FS_CATALOG_IMAGES)) {
          tep_db_query("update " . TABLE_MANUFACTURERS . " set manufacturers_image = '" . $manufacturers_image->filename . "' where manufacturers_id = '" . (int)$manufacturers_id . "'");
        }

So only if the upload is succesful, update the database.

 

Now, look at this upload class and see what kinds of checks are placed, and if necessary put some echo's in if you aren't getting the images uploaded in the expected location ...

 

HTH

Carine

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Link to comment
Share on other sites

Hi Aaron,

 

Long time since we touched base ....

 

I've been banging my head also with the image upload in the past.

Wasn't it on some poll code with images ?

 

Anyhow, the admin/manufacturers.php page is fairly simple and includes an image upload.

 

The key sample code in there:

         if ($manufacturers_image = new upload('manufacturers_image', DIR_FS_CATALOG_IMAGES)) {
          tep_db_query("update " . TABLE_MANUFACTURERS . " set manufacturers_image = '" . $manufacturers_image->filename . "' where manufacturers_id = '" . (int)$manufacturers_id . "'");
        }

So only if the upload is succesful, update the database.

 

Now, look at this upload class and see what kinds of checks are placed, and if necessary put some echo's in if you aren't getting the images uploaded in the expected location ...

 

HTH

Carine

 

 

Hey Carine!!

 

Yes, I looked at that before, but the way of working uploads on the manufacturers page is a little different. I still want to make it work with the code I have, but can't seem to figure it out. It would be a great addition to osCommerce and something that I would package and submit as a Contribution - if I could get it figured out. It's 90% done, I just can't get the file to upload for some reason. If you or anyone else could help that would be awesome! Thanks!

Link to comment
Share on other sites

Hey Carine!!

 

Yes, I looked at that before, but the way of working uploads on the manufacturers page is a little different. I still want to make it work with the code I have, but can't seem to figure it out. It would be a great addition to osCommerce and something that I would package and submit as a Contribution - if I could get it figured out. It's 90% done, I just can't get the file to upload for some reason. If you or anyone else could help that would be awesome! Thanks!

Don't you need to use the 'new upload' construction in order to actually upload the image to your server ?

I don't see any trace of that in your code ...

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Link to comment
Share on other sites

CORRECTION:

 

I think the product addition/modification page does use the type of code block you were recommending. I tried adding it, but it doesn't seem to change anything at all. Everything still works in the same way - all data getting to the database, but no file being uploaded.

 

<?php
/*
 $Id: products_extra_images.php,v 1.0 2003/06/11 Mikel Williams
 
 Advancements made by Aaron Hiatt 2005

 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');

// check if the catalog image directory exists
 if (is_dir(DIR_FS_CATALOG_IMAGES)) {
   if (!is_writeable(DIR_FS_CATALOG_IMAGES)) $messageStack->add(ERROR_CATALOG_IMAGE_DIRECTORY_NOT_WRITEABLE, 'error');
 } else {
   $messageStack->add(ERROR_CATALOG_IMAGE_DIRECTORY_DOES_NOT_EXIST, 'error');
 }
//BOF - Custom Hack for Extra Product Images Admin Interface //////////////////////////////////////////////	
 if ($HTTP_GET_VARS['action']) {
   switch ($HTTP_GET_VARS['action']) {
	 case 'update_extra_images':
	 $sql_data_array = array('products_extra_images_id' => tep_db_prepare_input($HTTP_POST_VARS['products_extra_images_id']),
                          'products_extra_image' => tep_db_prepare_input($HTTP_POST_VARS['products_extra_image']),
      	 'products_id' => tep_db_prepare_input($HTTP_POST_VARS['products_id']));
	 
	 //if (isset($HTTP_POST_VARS['products_extra_image']) && tep_not_null($HTTP_POST_VARS['products_extra_image']) && ($HTTP_POST_VARS['products_extra_image'] != 'none')) {
           //$sql_data_array['products_extra_image'] = tep_db_prepare_input($HTTP_POST_VARS['products_extra_image']);
         //}
   
	 tep_db_perform(TABLE_PRODUCTS_EXTRA_IMAGES, $sql_data_array, 'update', 'products_extra_images_id=' . tep_db_input($products_extra_images_id));
	 
	 $products_extra_image = new upload('products_extra_image');
           $products_extra_image->set_destination(DIR_FS_CATALOG_IMAGES);
           if ($products_extra_image->parse() && $products_extra_image->save()) {
           $products_extra_image_name = $products_extra_image->filename;
           } else {
           $products_extra_image_name = (isset($HTTP_POST_VARS['products_previous_image']) ? $HTTP_POST_VARS['products_previous_image'] : '');
           }
   
   tep_redirect(tep_href_link(FILENAME_PRODUCTS_EXTRA_IMAGES));
	 break;

	 case 'add_extra_images':
   $sql_data_array = array('products_extra_image' => tep_db_prepare_input($HTTP_POST_VARS['products_extra_image']),
                           'products_id' => tep_db_prepare_input($HTTP_POST_VARS['products_id']));
	 
	 //if (isset($HTTP_POST_VARS['products_extra_image']) && tep_not_null($HTTP_POST_VARS['products_extra_image']) && ($HTTP_POST_VARS['products_extra_image'] != 'none')) {
           //$sql_data_array['products_extra_image'] = tep_db_prepare_input($HTTP_POST_VARS['products_extra_image']);
         //}
   
  	 tep_db_perform(TABLE_PRODUCTS_EXTRA_IMAGES, $sql_data_array, 'insert');
	 
	 $products_extra_image = new upload('products_extra_image');
           $products_extra_image->set_destination(DIR_FS_CATALOG_IMAGES);
           if ($products_extra_image->parse() && $products_extra_image->save()) {
           $products_extra_image_name = $products_extra_image->filename;
           } else {
           $products_extra_image_name = (isset($HTTP_POST_VARS['products_previous_image']) ? $HTTP_POST_VARS['products_previous_image'] : '');
           }
	 
	 tep_redirect(tep_href_link(FILENAME_PRODUCTS_EXTRA_IMAGES));
	 break;

	 case 'delete_extra_images':
	 $sql_data_array = array('products_extra_images_id' => tep_db_prepare_input($HTTP_POST_VARS['products_extra_images_id']));
   tep_db_query("DELETE FROM " . TABLE_PRODUCTS_EXTRA_IMAGES . " WHERE products_extra_images_id=" . tep_db_input($products_extra_images_id));
   tep_redirect(tep_href_link(FILENAME_PRODUCTS_EXTRA_IMAGES));
	 break;
 }
}

$products_array = array(array('id' => '', 'text' => TEXT_NONE));
$products_query = tep_db_query("select p.products_id, p.products_model, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = pd.products_id order by products_model");
while ($products = tep_db_fetch_array($products_query)) {
 $products_array[] = array('id' => $products['products_id'],
         'text' => $products['products_name']);
}
//EOF - Custom Hack for Extra Product Images Admin Interface //////////////////////////////////////////////
?>
<!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; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
<script language="javascript" src="includes/general.js"></script>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onload="SetFocus();">
<div id="spiffycalendar" class="text"></div>
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->

<!-- body //-->
<table border="0" width="100%" cellspacing="2" cellpadding="2">
 <tr>
   <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">
<!-- 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 width="100%">
  <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_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
         </tr>
       </table>
   </td>
     </tr>
<TR>
 <TD width="100%" valign="top">  
	 <table width="100%" cellspacing="1" cellpadding="3">
 <tr class="dataTableHeadingRow">
   <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_PRODUCTS_ID; ?></td>
   <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_PRODUCTS_MODEL; ?></td>
   <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_PRODUCTS_IMAGE; ?></td>
<td class="dataTableHeadingContent"> </td>
 </tr>
 <?php 
//BOF - Custom Hack for Extra Product Images Admin Interface //////////////////////////////////////////////
 $products_extra_images_query = tep_db_query("SELECT pei.products_extra_image, pei.products_extra_images_id, pei.products_id, p.products_model FROM " . TABLE_PRODUCTS_EXTRA_IMAGES . " pei LEFT JOIN " . TABLE_PRODUCTS . " p ON pei.products_id = p.products_id order by p.products_model");
	 while ($extra_images = tep_db_fetch_array($products_extra_images_query)) {
?>
 <tr bgcolor=<?php echo $rowcolor; ?>>
 <?php echo tep_draw_form('extra_images_' . $extra_images['update_extra_images_id'], FILENAME_PRODUCTS_EXTRA_IMAGES, 'action=update_extra_images'); ?>
 <?php echo tep_draw_hidden_field('products_extra_images_id',$extra_images['products_extra_images_id']); ?>
   <td class="dataTableContent"><?php echo $extra_images['products_id'] ?></td>
   <td class="dataTableContent"><?php echo tep_draw_pull_down_menu('products_id', $products_array, $extra_images['products_id']); ?></td>	

<!--
<td class="dataTableContent"><?php echo tep_draw_input_field('products_extra_image',$extra_images['products_extra_image'],'size=50 value=' . $extra_images['products_extra_image']); ?></td>
-->

<td class="dataTableContent">
<?php echo tep_draw_file_field('products_extra_image') . '<br>Currently: ' . $extra_images['products_extra_image'] . tep_draw_hidden_field('products_previous_image', $extra_images['products_extra_image']); ?></td>

   <td class="dataTableContent">
<?php echo tep_image_submit('button_save.gif', IMAGE_SAVE); ?>
</form>
<?php echo tep_draw_form('extra_images_' . $extra_images['delete_extra_images_id'], FILENAME_PRODUCTS_EXTRA_IMAGES, 'action=delete_extra_images'); ?>
<?php echo tep_draw_hidden_field('products_extra_images_id',$extra_images['products_extra_images_id']); ?>
<?php echo tep_image_submit('button_delete.gif', IMAGE_DELETE); ?>
</form>
</td>
 </tr>
<?php
if ($rowcolor=='EEEEEE'){$rowcolor='FFFFFF';}
else {$rowcolor='EEEEEE';}
}
?>
 <tr bgcolor=<?php echo $rowcolor; ?>>
   <?php echo tep_draw_form('extra_images_' . $extra_images['add__extra_images'], FILENAME_PRODUCTS_EXTRA_IMAGES, 'action=add_extra_images'); ?>
<td class="dataTableContent"> </td>
   <td class="dataTableContent"><?php echo tep_draw_pull_down_menu('products_id', $products_array, $pInfo->products_id); ?></td>

<!--
   <td class="dataTableContent"><?php echo tep_draw_input_field('products_extra_image',$extra_images['products_extra_image'],'size=50'); ?></td>
-->

<td class="dataTableContent">
<?php echo tep_draw_file_field('products_extra_image') . tep_draw_hidden_field('products_previous_image', $extra_images['products_extra_image']); ?></td>

   <td class="dataTableContent"><?php echo tep_image_submit('button_save.gif', IMAGE_SAVE); ?></td>
</form>
 </tr>
 <tr>
   <td colspan="5"><br></td>
 </tr>
</table>
 </td>
<!-- body_text_eof //-->
 </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'); ?>

Link to comment
Share on other sites

I'd put some debuggin code in the upload class function to see why it's not uploading. Might be something to do with the path not existing on the server, or not properly permissioned (? 777)

Just guesses ....

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Link to comment
Share on other sites

I'd put some debuggin code in the upload class function to see why it's not uploading. Might be something to do with the path not existing on the server, or not properly permissioned (? 777)

Just guesses ....

 

That's a good idea, but I'm not exactly sure how to code that in per se for an upload class. Forms I can write from the groun dup OK, but haven't messed much with uploads. Any suggestions? I know it doesn't have to do with the directory not existing or not having the proper permissions, though. Already checked that out. Thanks!

 

-Aaron

Link to comment
Share on other sites

just find the upload function in the upload class (admin/includes/classes/upload.php) and put in some echo statements at different points to see what is going on

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Link to comment
Share on other sites

That's a good idea, but I'm not exactly sure how to code that in per se for an upload class. Forms I can write from the groun dup OK, but haven't messed much with uploads. Any suggestions? I know it doesn't have to do with the directory not existing or not having the proper permissions, though. Already checked that out. Thanks!

 

-Aaron

 

if you're still having a problem with this, i had the same problem when rewriting this contribution for another store i was working on... the problem lies not in the upload class, but in the form declaration... when you make your tep_draw_form statement that includes your upload button, make *sure* you do this:

 

Change:

 

<?php echo tep_draw_form('extra_images_' . $extra_images['update_extra_images_id'], FILENAME_PRODUCTS_EXTRA_IMAGES, 'action=update_extra_images'); ?>

 

To:

 

<?php echo tep_draw_form('extra_images_' . $extra_images['update_extra_images_id'], FILENAME_PRODUCTS_EXTRA_IMAGES,

'action=update_extra_images', 'post', 'enctype="multipart/form-data"'); ?>

 

Notice you have to add the 'enctype="multipart/form-data"' to the form declaration... took me forever to hunt that damned bug down, hope it helps :)

 

Richard Lindsey

 

p.s. Long live Chemo!!

Richard Lindsey

Link to comment
Share on other sites

if you're still having a problem with this, i had the same problem when rewriting this contribution for another store i was working on... the problem lies not in the upload class, but in the form declaration... when you make your tep_draw_form statement that includes your upload button, make *sure* you do this:

 

Change:

 

<?php echo tep_draw_form('extra_images_' . $extra_images['update_extra_images_id'], FILENAME_PRODUCTS_EXTRA_IMAGES, 'action=update_extra_images'); ?>

 

To:

 

                <?php echo tep_draw_form('extra_images_' . $extra_images['update_extra_images_id'], FILENAME_PRODUCTS_EXTRA_IMAGES,

'action=update_extra_images', 'post', 'enctype="multipart/form-data"'); ?>

 

Notice you have to add the 'enctype="multipart/form-data"' to the form declaration... took me forever to hunt that damned bug down, hope it helps :)

 

Richard Lindsey

 

p.s. Long live Chemo!!

 

 

 

Thanks for the advice Richard! Unfortunately that didn't seem to make any difference. With your code change the page works in writing info to the database (as it did before), but images still don't upload. Any other ideas? Thanks again for your time...

Link to comment
Share on other sites

Thanks for the advice Richard! Unfortunately that didn't seem to make any difference. With your code change the page works in writing info to the database (as it did before), but images still don't upload. Any other ideas? Thanks again for your time...

 

ah yes, there was one other thing i forgot to mention... you do need the "new upload" portion in the code... what happens is that the multipart form w/ the file field will automatically upload the file when the page is submitted, but the new upload constructor calls another function that checks the global FILES array, which is where the thing is stored temporarily, and it returns the data that's in that array for the content of the file... at that point you'll also want to make sure you save the file to your images directory... you should be able to get the info you need for these functions by looking at categories.php in your admin directory, and finding the parts where it uploads the initial product image :) Good luck!

 

Richard Lindsey.

Richard Lindsey

Link to comment
Share on other sites

ah yes, there was one other thing i forgot to mention... you do need the "new upload" portion in the code... what happens is that the multipart form w/ the file field will automatically upload the file when the page is submitted, but the new upload constructor calls another function that checks the global FILES array, which is where the thing is stored temporarily, and it returns the data that's in that array for the content of the file... at that point you'll also want to make sure you save the file to your images directory... you should be able to get the info you need for these functions by looking at categories.php in your admin directory, and finding the parts where it uploads the initial product image :) Good luck!

 

Richard Lindsey.

 

 

Thanks again Richard, but that's not doing anything either. All the variables are still writing to the database but the upload does not successfully happen.

 

-Aaron

Link to comment
Share on other sites

Thanks again Richard, but that's not doing anything either. All the variables are still writing to the database but the upload does not successfully happen.

 

-Aaron

 

if you'd like, i can post my rewritten products_extra_images.php and the language file for it, it's got a working file upload feature, uses the product's name (instead of model) in the left-most dropdown, and also displays the image once it's uploaded... if you don't have a thumbnailer installed, though, that can get a bit bandwidthy when assigning lots of images :D

 

Richard.

Richard Lindsey

Link to comment
Share on other sites

  • 4 weeks later...
if you'd like, i can post my rewritten products_extra_images.php and the language file for it, it's got a working file upload feature, uses the product's name (instead of model) in the left-most dropdown, and also displays the image once it's uploaded... if you don't have a thumbnailer installed, though, that can get a bit bandwidthy when assigning lots of images :D

 

Richard.

 

Will be nice if you can make a contribution with that velveeta :thumbsup:

Link to comment
Share on other sites

  • 2 weeks later...
  • 11 months later...

Noticed you guys are jazzin' up Extra Images, A mod I just installed. It's cute, but I was told that it would post the images in a way, so When I clicked the default product image, that default image would popup and have additional photos listed within that popup window to view other product images. I thought this would be cool, because the default product page wouldn't have to load more images, only the popup which would voluntarily be selected by the customer. Is this a feature and I installed it wrong or what?

We must be the change we wish to see in the world.

------------------------------------------------------------

p.s. BACKUP!

Link to comment
Share on other sites

  • 8 months later...

PLEASE please assist me - I get the following erro after installing the extra images contribution (1289)

 

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-20, 20' at line 1

 

select pei.products_extra_image, pei.products_extra_images_id, pei.products_id, pd.products_name,p.products_image from products_extra_images pei left join products p ON pei.products_id = p.products_id left join products_description pd on p.products_id = pd.products_id order by pd.products_name limit -20, 20

Link to comment
Share on other sites

  • 3 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...