Post by jonah » Mon Apr 30, 2012 2:24 am

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

Website Design, hosting, seo and online marketing visit: http://www.yorkcreative.co.uk


New member

Posts

Joined
Sun Feb 19, 2012 12:54 am

Post by ogov » Wed May 23, 2012 5:22 pm

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!

Newbie

Posts

Joined
Sat Nov 26, 2011 11:12 pm

Post by ogov » Wed May 23, 2012 5:50 pm

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!

Newbie

Posts

Joined
Sat Nov 26, 2011 11:12 pm
Who is online

Users browsing this forum: No registered users and 30 guests