change template to display filename
Posted: Mon Apr 30, 2012 2:24 am
Hi, in the product template there is this code for an upload option:
Does anyone please know what to add to this so that once an image file is uploaded on the product page that it displays the name of the file or even better a little thumbnail of the image?
Thanks for any help on this.
Code: Select all
<?php if ($options) { ?>
<script type="text/javascript" src="catalog/view/javascript/jquery/ajaxupload.js"></script>
<?php foreach ($options as $option) { ?>
<?php if ($option['type'] == 'file') { ?>
<script type="text/javascript"><!--
new AjaxUpload('#button-option-<?php echo $option['product_option_id']; ?>', {
action: 'index.php?route=product/product/upload',
name: 'file',
autoSubmit: true,
responseType: 'json',
onSubmit: function(file, extension) {
$('#button-option-<?php echo $option['product_option_id']; ?>').after('<img src="catalog/view/theme/default/image/loading.gif" class="loading" style="padding-left: 5px;" />');
},
onComplete: function(file, json) {
$('.error').remove();
if (json.success) {
alert(json.success);
$('input[name=\'option[<?php echo $option['product_option_id']; ?>]\']').attr('value', json.file);
}
if (json.error) {
$('#option-<?php echo $option['product_option_id']; ?>').after('<span class="error">' + json.error + '</span>');
}
$('.loading').remove();
}
});
//--></script>
<?php } ?>
<?php } ?>
<?php } ?>
Thanks for any help on this.
