Skip to content

Instantly share code, notes, and snippets.

@ericsaboia
Created January 14, 2013 22:01
Show Gist options
  • Save ericsaboia/4533936 to your computer and use it in GitHub Desktop.
Save ericsaboia/4533936 to your computer and use it in GitHub Desktop.
query.fileupload exemple
print $this->Html->script('jquery_file_upload/vendor/jquery.ui.widget');
print $this->Html->script('jquery_file_upload/jquery.iframe-transport');
print $this->Html->script('jquery_file_upload/jquery.fileupload');
$('input[type="file"]').fileupload({
acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i,
start: function() {
$('#'+$(this).attr('id')+'_loading').show();
},
done: function (e, data) {
if (typeof data.result == "object") {
var result = data.result[0].body.innerHTML;
} else {
var result = data.result;
}
$.each($.parseJSON(result), function (index, file) {
$("#option_"+file.option_id+"_media_loading").hide();
var img_source = file.path + '?' + new Date().getTime();
var img = '<img src="'+img_source+'"></img>';
$("#option_"+file.option_id+"_media_result").html(img);
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment