добавил проверку на размер файла в постах
This commit is contained in:
parent
d158c6624f
commit
f93d23f31f
@ -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>
|
||||
Loading…
Reference in New Issue
Block a user