[gelöst] File und HTML Popuptext Upload funktioniert nicht

Begonnen von AlternativeComputing, 07 Dezember 2012, 18:31:22

⏪ vorheriges - nächstes ⏩

0 Mitglieder und 1 Gast betrachten dieses Thema.

AlternativeComputing

Moin Moin,

Ich bin gerade dabei die letzten großen Bugs zu beheben und stoße gerade an meine Grenzen.

In der categories.php im osc4pmx ACP ist ein Mutifile Upload verbaut, der auch im Original osCommerce funktioniert.
Nur mit dem PMX werden die POST Daten nicht übergeben.
Es werden weder die Daten in die DB und die Bilder in den Upload-Ordner gespeichert, aber auch nur die Großen Bilder und deren PopUp Beschreibungen.

Alle anderen Daten und das Main Produktbild werden ordnungsgemäß gespeichert.

Vielleicht findet Ihr ja eine Lösung.

Die betreffenden Zeilen in der categories.php:

Das Array in den die Daten gesammelt werden:
Zeile: 353 - 392:

        $pi_sort_order = 0;
        $piArray = array(0);

        foreach ($_FILES as $key => $value) {
// Update existing large product images
          if (preg_match('/^products_image_large_([0-9]+)$/', $key, $matches)) {
            $pi_sort_order++;

            $sql_data_array = array('htmlcontent' => mxPrepareToDisplay($_POST['products_image_htmlcontent_' . $matches[1]]),
                                    'sort_order' => $pi_sort_order);

            $t = new uploads($key);
            $t->set_destination($root_images_dir . $dir);
            if ($t->parse() && $t->save()) {
              $sql_data_array['image'] = $dir . mxPrepareToDisplay($t->filename);
            }

            osc4pmx_perform(TABLE_PRODUCTS_IMAGES, $sql_data_array, 'update', "products_id = '" . (int)$products_id . "' and id = '" . (int)$matches[1] . "'");

            $piArray[] = (int)$matches[1];
          } elseif (preg_match('/^products_image_large_new_([0-9]+)$/', $key, $matches)) {
// Insert new large product images
            $sql_data_array = array('products_id' => (int)$products_id,
                                    'htmlcontent' => mxPrepareToDisplay($_POST['products_image_htmlcontent_new_' . $matches[1]]));

            $t = new uploads($key);
            $t->set_destination($root_images_dir . $dir);
            if ($t->parse() && $t->save()) {
              $pi_sort_order++;

              $sql_data_array['image'] = $dir . mxPrepareToDisplay($t->filename);
              $sql_data_array['sort_order'] = $pi_sort_order;

              osc4pmx_perform(TABLE_PRODUCTS_IMAGES, $sql_data_array);

              $piArray[] = sql_insert_id();
            }
          }
        }



Die Formzeilen:

Zeile: 939 - 1006:

          <tr>
            <td class="main" valign="top"><?php echo TEXT_PRODUCTS_IMAGE?></td>
            <td class="main" style="padding-left: 30px;">
              <div><?php echo '<strong>' TEXT_PRODUCTS_MAIN_IMAGE ' <small>(' SMALL_IMAGE_WIDTH ' x ' SMALL_IMAGE_HEIGHT 'px)</small></strong><br />' . (tep_not_null($pInfo->products_image) ? '<a href="' DIR_WS_CATALOG_IMAGES $pInfo->products_image '" target="_blank">' $pInfo->products_image '</a> &#38;#124; ' '') . tep_draw_file_field('products_image'); ?></div>

              <ul id="piList">
<?php
    $pi_counter 
0;

    foreach (
$pInfo->products_larger_images as $pi) {
      
$pi_counter++;

      echo 
'                <li id="piId' $pi_counter '" class="ui-state-default"><span class="ui-icon ui-icon-arrowthick-2-n-s" style="float: right;"></span><a href="#" onclick="showPiDelConfirm(' $pi_counter ');return false;" class="ui-icon ui-icon-trash" style="float: right;"></a><strong>' TEXT_PRODUCTS_LARGE_IMAGE '</strong><br />' tep_draw_file_field('products_image_large_' $pi['id']) . '<br /><a href="' DIR_WS_CATALOG_IMAGES $pi['image'] . '" target="_blank">' $pi['image'] . '</a><br /><br />' TEXT_PRODUCTS_LARGE_IMAGE_HTML_CONTENT '<br />' tep_draw_textarea_field('products_image_htmlcontent_' $pi['id'], 'soft''70''3'$pi['htmlcontent']) . '</li>';
    }
?>

              </ul>

              <a href="#" onclick="addNewPiForm();return false;"><span class="ui-icon ui-icon-plus" style="float: left;"></span><?php echo TEXT_PRODUCTS_ADD_LARGE_IMAGE?></a>

<div id="piDelConfirm" title="<?php echo TEXT_PRODUCTS_LARGE_IMAGE_DELETE_TITLE?>">
  <p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span><?php echo TEXT_PRODUCTS_LARGE_IMAGE_CONFIRM_DELETE?></p>
</div>

<style type="text/css">
#piList { list-style-type: none; margin: 0; padding: 0; }
#piList li { margin: 5px 0; padding: 2px; }
</style>

<script type="text/javascript">
$('#piList').sortable({
  containment: 'parent'
});

var piSize = <?php echo $pi_counter?>;

function addNewPiForm() {
  piSize++;

  $('#piList').append('<li id="piId' + piSize + '" class="ui-state-default"><span class="ui-icon ui-icon-arrowthick-2-n-s" style="float: right;"></span><a href="#" onclick="showPiDelConfirm(' + piSize + ');return false;" class="ui-icon ui-icon-trash" style="float: right;"></a><strong><?php echo TEXT_PRODUCTS_LARGE_IMAGE?></strong><br /><input type="file" name="products_image_large_new_' + piSize + '" /><br /><br /><?php echo TEXT_PRODUCTS_LARGE_IMAGE_HTML_CONTENT?><br /><textarea name="products_image_htmlcontent_new_' + piSize + '" wrap="soft" cols="70" rows="3"></textarea></li>');
}

var piDelConfirmId = 0;

$('#piDelConfirm').dialog({
  autoOpen: false,
  resizable: false,
  draggable: false,
  modal: true,
  buttons: {
    'Delete': function() {
      $('#piId' + piDelConfirmId).effect('blind').remove();
      $(this).dialog('close');
    },
    Cancel: function() {
      $(this).dialog('close');
    }
  }
});

function showPiDelConfirm(piId) {
  piDelConfirmId = piId;

  $('#piDelConfirm').dialog('open');
}
</script>

            </td>
          </tr>


Ich hänge mal die uploads.php mit der Upload Class mit an, sowie die categories.php und die deutsche Langfile categories.php.

Den Order admin einfach in den Ordner Catalog kopieren.
MfG

Peter

AlternativeComputing

Moin Moin ,

Ich bin jetzt schon mal bissel schlauer.
Nach dem ich im osc4pmx Admin Header


<pre><?php echo var_dump($_FILES); ?></pre>


eingefügt habe und in der categories.php die Zeile 415 auskommentiert habe


         sql_query("delete from " . TABLE_PRODUCTS_IMAGES . " where products_id = '" . intval($products_id) . "' and id not in (" . implode(',', $piArray) . ")");
       }

       if (USE_CACHE == 'true') {
         tep_reset_cache_block('categories');
         tep_reset_cache_block('also_purchased');
       }

//        tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $products_id)); // Zeile 415
       break;
     case 'copy_to_confirm':


Bekomme ich auch die Fehlermeldungen wieder angezeigt und mußte feststellen, das die ganzen einzeln Arrays alle gefüllt werden, nur das Multi Array für den Großen Bilder und Popup Text Upload nicht.
Dieses Array wird zwar befüllt, aber auch immer nur mit der zuletzt ausgewählten Datei und beim HTML Text verhält es sich identisch wie bei den Dateien.


var_dump($_FILES):

array(7) {
 ["availability_id_out_of_stock_image"]=>
 array(5) {
   ["name"]=>
   string(0) ""
   ["type"]=>
   string(0) ""
   ["tmp_name"]=>
   string(0) ""
   ["error"]=>
   int(4)
   ["size"]=>
   int(0)
 }
 ["availability_id_in_stock_image"]=>
 array(5) {
   ["name"]=>
   string(0) ""
   ["type"]=>
   string(0) ""
   ["tmp_name"]=>
   string(0) ""
   ["error"]=>
   int(4)
   ["size"]=>
   int(0)
 }
 ["availability_id_in_stock2_image"]=>
 array(5) {
   ["name"]=>
   string(0) ""
   ["type"]=>
   string(0) ""
   ["tmp_name"]=>
   string(0) ""
   ["error"]=>
   int(4)
   ["size"]=>
   int(0)
 }
 ["availability_id_in_stock3_image"]=>
 array(5) {
   ["name"]=>
   string(0) ""
   ["type"]=>
   string(0) ""
   ["tmp_name"]=>
   string(0) ""
   ["error"]=>
   int(4)
   ["size"]=>
   int(0)
 }
 ["availability_id_in_stock_special_image"]=>
 array(5) {
   ["name"]=>
   string(0) ""
   ["type"]=>
   string(0) ""
   ["tmp_name"]=>
   string(0) ""
   ["error"]=>
   int(4)
   ["size"]=>
   int(0)
 }
 ["products_image"]=>
 array(5) {
   ["name"]=>
   string(0) ""
   ["type"]=>
   string(0) ""
   ["tmp_name"]=>
   string(0) ""
   ["error"]=>
   int(4)
   ["size"]=>
   int(0)
 }

// Hier beginnt der Multifile Upload:

 ["products_image_large_new_NaN"]=>
 array(5) {
   ["name"]=>
   string(16) "galaxy_tab_4.jpg"
   ["type"]=>
   string(10) "image/jpeg"
   ["tmp_name"]=>
   string(14) "/tmp/phpc3ajyN"
   ["error"]=>
   int(0)
   ["size"]=>
   int(57501)
 }
}


PMX Debug-Info

Übergabeparameter (Request):

GET:
action => update_product
cPath => 21
file => categories
op => oscpmxadmin
pID => 31

POST:
availability_id_in_stock => 1
availability_id_in_stock2 => 3
availability_id_in_stock2_previous_image => yellow.png
availability_id_in_stock3 => 1
availability_id_in_stock3_previous_image => green.png
availability_id_in_stock_previous_image => red.png
availability_id_in_stock_special => 5
availability_id_in_stock_special_previous_image => lila.png
availability_id_out_of_stock => 2
availability_id_out_of_stock_previous_image => remove.png
availability_image_status => 0
availability_status => 0
directory => test
manufacturers_id => 11
new_directory =>
products_baseprice => 0.0000
products_baseprice_gross => 0
products_baseprice_unit =>
products_date_added => 2012-08-17 02:17:57
products_date_available =>
products_description => Array
(
   [1] => <p>Test</p>
<p><br /></p>
<p>Dies ist ein Testprodukt.</p>
   [2] =>
   [3] => Test
   [4] =>
   [5] =>
)

// Beginn Multi File / HTML Upload:

products_image_htmlcontent_new_NaN =>
// Ende Multi File / HTML Upload

products_model => 0156654
products_name => Array
(
   [1] => Test
   [2] =>
   [3] => Test
   [4] =>
   [5] =>
)
products_price => 1.9900
products_price_gross => 2.3681
products_quantity => 99997
products_status => 1
products_tax_class_id => 2
products_url => Array
(
   [1] =>
   [2] =>
   [3] =>
   [4] =>
   [5] =>
)
products_weight => 0.00
quantity_stock => 0
quantity_stock_2 => 0
quantity_stock_3 => 0
quantity_stock_special => 0
quantity_stock_zero => 0
warranty_id => 1
warranty_image_status => 0
warranty_status => 0
wysiwyg_products_description => Array
(
   [1] => 1
   [2] => 1
   [3] => 1
   [4] => 1
   [5] => 1
)

COOKIE:
cookie_test => please_accept_for_session
tab_account => 0
tab_account_index => 1
tab_modadmin => 0
tab_product_info => 0
tab_reviews => 0
tab_usersconfig => 4
testing => 1

FILES:
availability_id_in_stock2_image => Array
(
   [name] =>
   [type] =>
   [tmp_name] =>
   [error] => 4
   [size] => 0
)
availability_id_in_stock3_image => Array
(
   [name] =>
   [type] =>
   [tmp_name] =>
   [error] => 4
   [size] => 0
)
availability_id_in_stock_image => Array
(
   [name] =>
   [type] =>
   [tmp_name] =>
   [error] => 4
   [size] => 0
)
availability_id_in_stock_special_image => Array
(
   [name] =>
   [type] =>
   [tmp_name] =>
   [error] => 4
   [size] => 0
)
availability_id_out_of_stock_image => Array
(
   [name] =>
   [type] =>
   [tmp_name] =>
   [error] => 4
   [size] => 0
)
products_image => Array
(
   [name] =>
   [type] =>
   [tmp_name] =>
   [error] => 4
   [size] => 0
)

// Hier beginnt der Multifile Upload:

products_image_large_new_NaN => Array
(
   [name] => galaxy_tab_4.jpg
   [type] => image/jpeg
   [tmp_name] => /tmp/phpc3ajyN
   [error] => 0
   [size] => 57501
)


Es kommen also Daten im Array und auf dem Server an, nur nicht alle. Die des Multifile Uploads halt nicht.
MfG

Peter

AlternativeComputing

Moin Moin  :morning:

Soo der Uploadfehler ist schon mal behoben. Nun kommen die Dateien auch auf dem Server an.
Es lag an dem


preg_match('/^products_image_large_new_([0-9]+)$/', $key, $matches)


Für das osc4pmx müste es aber


preg_match('/^products_image_large_new_([a-zA-Z0-9]+)$/', $key, $matches)


sein.
Das Array Problem hatte ich heute Nacht mal gelöst bekommen und nun finde ich den Ansatz nicht wieder.
Es wird also zur Zeit immer nur das letzte Bild gespeichert.
MfG

Peter

AlternativeComputing

Moin Moin,

Konnte nun den kompletten Bug beheben.

-- Closed --
MfG

Peter