Created
January 14, 2013 22:01
-
-
Save ericsaboia/4533936 to your computer and use it in GitHub Desktop.
query.fileupload exemple
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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