Skip to content
Snippets Groups Projects
Commit 15ed9d81 authored by me5na7qbjqbrp's avatar me5na7qbjqbrp
Browse files

Check image size before sending it

parent de3660b2
No related branches found
No related tags found
2 merge requests!113Fix note pictures, better ansible,!112Move image upload code to form clean
Pipeline #8659 passed with warnings with stages
in 10 minutes and 6 seconds
......@@ -55,12 +55,18 @@ SPDX-License-Identifier: GPL-3.0-or-later
/* SCRIPT TO OPEN THE MODAL WITH THE PREVIEW */
$("#id_image").change(function (e) {
if (this.files && this.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$("#modal-image").attr("src", e.target.result);
$("#modalCrop").modal("show");
// Check the image size
if (this.files[0].size > 2*1024*1024) {
alert("Ce fichier est trop volumineux.")
} else {
// Read the selected image file
var reader = new FileReader();
reader.onload = function (e) {
$("#modal-image").attr("src", e.target.result);
$("#modalCrop").modal("show");
}
reader.readAsDataURL(this.files[0]);
}
reader.readAsDataURL(this.files[0]);
}
});
......@@ -104,4 +110,4 @@ SPDX-License-Identifier: GPL-3.0-or-later
});
});
</script>
{% endblock %}
\ No newline at end of file
{% endblock %}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment