0

I'm trying upload product pictures without image manager directly from My Computer window, for example like it is possible on facebook.

So, in admin/view/template/catalog/product_form.tpl file in code that responsible of product image I put:

id="anyword"

to the following:

<a onclick="image_upload('image', 'thumb');" id="anyword"><?php echo $text_browse; ?></a>

instead of:

onclick="image_upload('image', 'thumb');"

to become:

<tr>
          <td><?php echo $entry_image; ?></td>
          <td><div class="image"><img src="<?php echo $thumb; ?>" alt="" id="thumb" /><br />
              <input type="hidden" name="image" value="<?php echo $image; ?>" id="image" />
              <a id="anyword"><?php echo $text_browse; ?></a>&nbsp;&nbsp;|&nbsp;&nbsp;<a onclick="$('#thumb').attr('src', '<?php echo $no_image; ?>'); $('#image').attr('value', '');"><?php echo $text_clear; ?></a></div></td>
        </tr>

And add in end of page:

<script type="text/javascript" src="admin/view/javascript/jquery/ajaxupload.js"></script>
<script type="text/javascript"><!--
$(document).ready(function() {    
new AjaxUpload('#anyword, {
  action: 'index.php?route=common/filemanager/upload&image=' +       encodeURIComponent($('#image').attr('value')),
  name: 'image',
  autoSubmit: true,
  responseType: 'json',

  onChange: function(file, extension) {

     this.setData({'directory': ''});
     this.submit();
  },

  onSubmit: function(file, extension) {
     $('#upload').append('<img src="admin/view/image/loading.gif" class="loading" style="padding-   left: 5px;" />');
  },
  onComplete: function(file, json) {
     if (json.success) {
        $('#image').attr('value','data/user/'+file);
        $.ajax({
           url: 'index.php?route=common/filemanager/image&image=' +      encodeURIComponent($('#image').attr('value')),
           dataType: 'text',
           success: function(text) {
              $('#thumb').replaceWith('<img src="' + text + '" alt="" id="thumb" />');                        
           }
        });
     }

     if (json.error) {
        alert(json.error);
     }

     $('.loading').remove();   
  }
});


});

//--></script> 

But it doesn't work for me :(

Can anyone help?!

Merkucio
  • 175
  • 1
  • 4
  • 19
  • http://stackoverflow.com/questions/24168040/upload-multiple-files-with-php-and-jquery/24168617#24168617 – Alexander Ceballos Sep 26 '14 at 19:52
  • Don't see what is common – Merkucio Sep 27 '14 at 03:50
  • *But it doesn't work for me* - means that nothing happens if you click on the upload button or you get some JS error in browser's console or everything seems to be working except the file is not uploaded, or...? It would be very helpful if you could describe that *not working* behavior in more details in the future. Can you post here a link to that AjaxUpload plugin you are using (better to it's documentation directly)? – shadyyx Sep 29 '14 at 07:13
  • I made a such extension for opencart 2.0 Sorry i do not plan to update it, i'm not so motivated anymore. You can install opencart 2.0 and see how it works https://www.opencart.com/index.php?route=marketplace/extension/info&extension_id=22144 – Abdallah B Nov 15 '20 at 16:48

1 Answers1

1

At 4th line in javascript code

new AjaxUpload('#anyword, {

you forget to close '#anyword, to become '#anyword',

try change and it will work