Skip to content

Instantly share code, notes, and snippets.

@nickbewley
Last active August 29, 2015 14:17
Show Gist options
  • Save nickbewley/cbc04863b0b1c5598746 to your computer and use it in GitHub Desktop.
Save nickbewley/cbc04863b0b1c5598746 to your computer and use it in GitHub Desktop.
Axure File Upload and Save — Send to Parse
// Add your parse App Id and Javascript Id here
var parse_app_id = "YOUR_PARSE_APP_ID" // App ID
var parse_javascript_id = "YOUR_PARSE_JS_ID" // JS ID
// Start Parse
Parse.initialize(parse_app_id, parse_javascript_id);
// When the file input changes (ie. a file has been added)
$('#UploadInput').bind("change", function(e) {
var fileUploadControl = $("#UploadInput")[0];
var file = fileUploadControl.files[0];
var name = file.name;
$.trim($(name).text()); // Strip the whitespace on the ends if there is any...
var parseFile = new Parse.File(name, file); //create a Parse Variable
// Save the file to Parse
parseFile.save().then(function() {
var imageUpload = new Parse.Object("Image"); // "Image" = the name of your Parse Class
imageUpload.set("Name", "Joe Smith"); // this is a sample additional piece of information to add to Parse.. Can be anything
imageUpload.set("theImage", parseFile);
imageUpload.save();
}, function(error) {
//error handling
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment