Merkucio
Merkucio

Reputation: 175

upload images without image manager in opencart 1.5.5.1

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?!

Upvotes: 0

Views: 1466

Answers (1)

Haitham Shehata
Haitham Shehata

Reputation: 30

At 4th line in javascript code

new AjaxUpload('#anyword, {

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

try change and it will work

Upvotes: 1

Related Questions