добавил проверку на размер файла в постах

This commit is contained in:
developer 2026-05-06 13:00:34 +08:00
parent d158c6624f
commit f93d23f31f

View File

@ -61,4 +61,20 @@
@enderror
</div>
<button type="submit" class="btn btn-primary">Сохранить</button>
</form>
</form>
<script>
const fileInput = document.getElementById('formFile');
const maxSize = 1 * 1024 * 1024; // 1 МБ в байтах
fileInput.addEventListener('change', function () {
if (this.files.length > 0) {
const file = this.files[0];
if (file.size > maxSize) {
alert('Файл больше 1 МБ! Пожалуйста, выберите другой файл.');
this.value = ''; // очищаем input
}
}
});
</script>