Javascript-форум (https://javascript.ru/forum/)
-   Firefox/Mozilla (https://javascript.ru/forum/css-html-firefox-mizilla/)
-   -   Ограничение загружаемого файла (https://javascript.ru/forum/css-html-firefox-mizilla/48908-ogranichenie-zagruzhaemogo-fajjla.html)

artiom-75 21.07.2014 17:21

Ограничение загружаемого файла
 
Уважаемые знатоки есть код загрузки файла.
<script>
function readURL(input) {  if(!/(\.bmp|\.gif|\.jpg|\.jpeg|\.png)$/i.test(input.value)) {
	alert('Error');
	document.getElementById('image_p').value='';return false;
	}
if (input.files && input.files[0]) {
var reader = new FileReader();

reader.onload = function (e) {
$('#img_prev')
.attr('src', e.target.result)
.width(150);
};

reader.readAsDataURL(input.files[0]);
}
}
</script>
<input type="file" id="image_p" name="attachment[]" onchange="readURL(this);" />
<img id="img_prev" class="image_block" src="image.png" alt="" />

Что нужно добавить в коде, чтобы было ограничение загружаемого файла до 0.5 мегабайт и размеры картинки: ширина до 1024-пиксель, высота до 768-пиксель?


Часовой пояс GMT +3, время: 10:28.