Horje
upload file  check the file type Code Example
upload file check the file type
var _validFileExtensions = [".jpg", ".jpeg", ".bmp", ".gif", ".png"];    
function Validate(oForm) {
    var arrInputs = oForm.getElementsByTagName("input");
    for (var i = 0; i < arrInputs.length; i++) {
        var oInput = arrInputs[i];
        if (oInput.type == "file") {
            var sFileName = oInput.value;
            if (sFileName.length > 0) {
                var blnValid = false;
                for (var j = 0; j < _validFileExtensions.length; j++) {
                    var sCurExtension = _validFileExtensions[j];
                    if (sFileName.substr(sFileName.length - sCurExtension.length, sCurExtension.length).toLowerCase() == sCurExtension.toLowerCase()) {
                        blnValid = true;
                        break;
                    }
                }
                
                if (!blnValid) {
                    alert("Sorry, " + sFileName + " is invalid, allowed extensions are: " + _validFileExtensions.join(", "));
                    return false;
                }
            }
        }
    }
  
    return true;
}




Whatever

Related
hypercorn initiate Code Example hypercorn initiate Code Example
Uncaught Error: Class 'NOOP_Translations' not found Code Example Uncaught Error: Class 'NOOP_Translations' not found Code Example
How to put water while falling like dream Code Example How to put water while falling like dream Code Example
geth terminology Code Example geth terminology Code Example
wp_localize_script was called incorrectly Code Example wp_localize_script was called incorrectly Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
7