Skip to content

Instantly share code, notes, and snippets.

@shrimpwagon
Last active April 20, 2017 14:54
Show Gist options
  • Save shrimpwagon/5363cf917970cea88bb4fd45da9761d1 to your computer and use it in GitHub Desktop.
Save shrimpwagon/5363cf917970cea88bb4fd45da9761d1 to your computer and use it in GitHub Desktop.
HTML5 Image Uploader Example HTML/PHP
<html>
<head>
<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
<script src="html5-image-uploader.jquery.js"></script>
<script>
$(document).ready(function() {
$('#file').postFile({
url: 'http://example.com/upload',
data: {
uniqid: '<?php echo $uniqid ?>'
},
onProgress: function($elem, file, xhr, file_id, position, total, percentage) {
console.log(file.name + ': ' + position + ' of ' + total + ' ' + percentage + '%');
},
onSuccess: function(data, $elem, file, xhr, file_id) {
console.log(file.name + ' uploaded!');
}
});
});
</script>
</head>
<body>
Upload file: <input type="file" id="file" multiple>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment