mirror of
https://gitlab.crans.org/bde/nk20
synced 2024-11-30 04:13:01 +00:00
Check image size before sending it
This commit is contained in:
parent
de3660b23c
commit
15ed9d81d5
@ -55,6 +55,11 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
/* SCRIPT TO OPEN THE MODAL WITH THE PREVIEW */
|
/* SCRIPT TO OPEN THE MODAL WITH THE PREVIEW */
|
||||||
$("#id_image").change(function (e) {
|
$("#id_image").change(function (e) {
|
||||||
if (this.files && this.files[0]) {
|
if (this.files && this.files[0]) {
|
||||||
|
// 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();
|
var reader = new FileReader();
|
||||||
reader.onload = function (e) {
|
reader.onload = function (e) {
|
||||||
$("#modal-image").attr("src", e.target.result);
|
$("#modal-image").attr("src", e.target.result);
|
||||||
@ -62,6 +67,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
}
|
}
|
||||||
reader.readAsDataURL(this.files[0]);
|
reader.readAsDataURL(this.files[0]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/* SCRIPTS TO HANDLE THE CROPPER BOX */
|
/* SCRIPTS TO HANDLE THE CROPPER BOX */
|
||||||
|
Loading…
Reference in New Issue
Block a user