Skip to content

Instantly share code, notes, and snippets.

@brucenorton
Created May 7, 2017 22:11
Show Gist options
  • Save brucenorton/01213adeb65c177643b45472a17cee7d to your computer and use it in GitHub Desktop.
Save brucenorton/01213adeb65c177643b45472a17cee7d to your computer and use it in GitHub Desktop.
cloudinary upload.js that works
$(function () {
"use strict";
$.post( "upload_tags.php", function( data ) {
$( "#uploadForm" ).html( data );
//The idea is to only load this once someone has filled out the form
let newContext = 'email=new@test.com|credits=Me New Context';
$('.cloudinary-fileupload')
.cloudinary_fileupload({
dropZone: '#direct_upload',
context: newContext,
start: function () {
$('.status_value').text('Starting direct upload...');
},
progress: function () {
$('.status_value').text('Uploading...');
}
})
.bind('fileuploadprogress', function(e, data) {
$('.progress_bar').css('width', Math.round((data.loaded * 100.0) / data.total) + '%');
})
.on('cloudinarydone', function (e, data) {
$('.status_value').text('Idle');
$.post('upload_complete.php', data.result);
var info = $('<div class="uploaded_info"/>');
$(info).append($('<div class="data"/>').append(prettydump(data.result)));
$(info).append($('<div class="image"/>').append(
$.cloudinary.image(data.result.public_id, {
format: data.result.format, width: 450, height: 450, crop: "fill"
})
));
$('.uploaded_info_holder').append(info);
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment