Skip to content

Instantly share code, notes, and snippets.

@nbr23
Created October 16, 2019 03:44
Show Gist options
  • Save nbr23/7bf9c96f2f03ad5f69404bdb7c11045c to your computer and use it in GitHub Desktop.
Save nbr23/7bf9c96f2f03ad5f69404bdb7c11045c to your computer and use it in GitHub Desktop.
Image title:<br/>
<input type="text" id="title"/><br/>
Sender name:<br/>
<input type="text" id="from"/><br/>
Image:<br/>
<input type="file" id="blob"/><br/>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script>
function handleFileSelect(evt) {
var reader = new FileReader();
var file = evt.target.files[0];
reader.readAsDataURL(file);
reader.onloadend = function() {
base64data = reader.result;
base64data = base64data.substr(base64data.indexOf('base64,') + 7);
name = document.getElementById('title').value
sender = document.getElementById('from').value
$.post($SNAP_API, JSON.stringify({ From: sender, Name: name, Blob: base64data}));
}
}
document.getElementById('blob').addEventListener('change', handleFileSelect, false);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment