Antrium A35D

Bir sonraki için en iyisini yap...

How to check if input file is empty in jQuery, Jquery fileupload check,upload check,Jquery dosya upload kontrol

How to check if input file is empty in jQuery, Jquery fileupload check,upload check,Jquery dosya upload kontrol

if (document.getElementById("r1").files.length == 0) {
    alert('Dosya Seçiniz.\r\nİzin verilen uzantılar; doc,docx,pdf');
    return false;
}

var file = $("#r1");
var size = parseFloat(file[0].files[0].size);
var maxSizeKB = 10240; //Size in KB.
var maxSize = maxSizeKB * 1024; //File size is returned in Bytes.
if (size > maxSize) {
    alert("Maksimum " + (maxSizeKB / 1024) + "MB İzin Veriliyor..");
    file.val("");
    return false;
}

var ext = $('#r1').val().split('.').pop().toLowerCase();
if ($.inArray(ext, ['doc', 'docx', 'pdf']) == -1) {
    alert('İzin Verilmeyen Dosya Biçimi.\r\nİzin verilen uzantılar; doc,docx,pdf');
    return false;
}

166 Okunma | 7.12.2023 15:48

YORUMLAR

Yorum Yaz
Hüseyin ÖZKAN Yazılım Uzmanı

C#,MVC,MSSQL,Windows Forms