-
-
Save Fanna1119/f803a012fa46034b699f707920ad6b64 to your computer and use it in GitHub Desktop.
img compress.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('form').submit(function (e) { | |
e.preventDefault(); | |
var formData = new FormData($(this)); | |
var image_file = $("#file_select")[0].files[0]; | |
if (!image_file) { | |
return; | |
} | |
new ImageCompressor(image_file, { | |
quality: 0.6, | |
success(result) { | |
formData.append('image', result, result.name); | |
console.log(result); | |
}, | |
error(e) { | |
console.log(e.message); | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment