Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $('#image').change(function(e) {
- var file = e.target.files[0];
- if (file.type == '') {
- admin.status('Unknown file type');
- return true;
- }
- if (!file.type.match('image.*')) {
- admin.status('Your file must be a proper image');
- return true;
- }
- var reader = new FileReader();
- var content = '';
- reader.onload = (function(theFile) {
- return function(e) {
- admin.notify('Uploading Image.. 0%');
- var xhr = new XMLHttpRequest();
- xhr.open('POST', '/ajx/image.php', true);
- xhr.upload.onprogress = function(e) {
- var progress = Math.round((e.loaded / e.total) * 100) + '%';
- $('.notify').html('Uploading Image.. ' + progress);
- };
- xhr.upload.onloadend = function(response) {
- admin.status('Upload Complete');
- console.log(e);
- console.log(xhr.status);
- console.log(xhr.response);
- };
- xhr.send(e.target.result);
- };
- })(file);
- reader.readAsBinaryString(file);
- });
- },
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement