Skip to content

Instantly share code, notes, and snippets.

@MauMaGau
Created May 2, 2012 19:06
Show Gist options
  • Save MauMaGau/2579345 to your computer and use it in GitHub Desktop.
Save MauMaGau/2579345 to your computer and use it in GitHub Desktop.
JQuery: qqFileUploader video upload
$(function() {
var base_url = $('base').attr('href');
gallery_id = $('input[name=gallery_id]').val();
/* Uploader */
var uploader = new qq.FileUploader({
element: document.getElementById('file-uploader'),
action: base_url+'gallery/upload/'+gallery_id+'/ajax',
debug: false,
onComplete: function(id, fileName, response){
if(response.success == true){
var preview = '';
var errors = '';
for(var i=0;i<response.data.length;i++){
if(response.data[i].type == 0){
var type = 'jpg';
var file_name = response.data[i].file_name + '.' + type;
preview = preview+"<li><img src='"+base_url+"user_uploads/image/200/"+ file_name + "'/></li>";
}else if(response.data[i].type == 1){
var type = 'jpg';
var file_name = response.data[i].file_name + '.' + type;
preview = preview+"<li>Video rendering in background... You can continue to use the site as normal. Your video will appear in the gallery once it has finished rendering. This usually takes less than 5 minutes.</li>";
}else if(response.data[i].type == 'error'){
errors = errors+response.errors;
preview = preview+"<span class='error'>"+errors+"</span>";
}
}
} else {
}
$('#upload-status ul').append(preview);
$('ul.qq-upload-list').html('<li>Upload Successful. <a href=\''+base_url+'gallery/edit/'+gallery_id+'\'>Refresh</a> page to edit new uploads.</li>');
},
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment