Page 1 of 1

change template to display filename

Posted: Mon Apr 30, 2012 2:24 am
by jonah
Hi, in the product template there is this code for an upload option:

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 } ?>
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. :)

Re: change template to display filename

Posted: Wed May 23, 2012 5:22 pm
by ogov
Hi,

Im also looking for this feature, any progress?

What I have figured out is;
image is being uploaded to
/download
folder at the root
with following kind of random name
1337691777_personal.png.b580555d10b49763ee44e19becaec798

after successful upload, the upload form element getting the following value;
<input type="hidden" value="ZmRlampuYmlqa5Shl6WnpJ+Tn2Kln5lhlmppYmhpapVjY5ZpamlpZ5qWZmeZZmqUmJeWlpVqbW0=" name="option[404]">

I think what we have to do is, to figure out the relationship btw these to have the file name which has uploaded to /download folder :)

I will get back soon if I make any progress.

Best Wishes!

Re: change template to display filename

Posted: Wed May 23, 2012 5:50 pm
by ogov
I have found the
upload php script
at the controller/product/product.php

and see OC is adding a . md5(rand()) after file extension
and also encrypting the json value to for the following reason
"// Hide the uploaded file name sop people can not link to it directly."

Thats clever :)

Now here comes a choice for us, will we ignore the risk?
or be safe with OC defaults :)

Best wishes!