summaryrefslogtreecommitdiffstats
path: root/ecomp-portal-widget-ms/widget-ms/src/main/resources/templates/Upload.html
blob: 01e0564b2a08ac91a7dc42ed71b65fab5f6740ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<html>
<script>
var validFileExtensions = [".zip"];    
function validateInput(form) {
    var arrInputs = form.getElementsByTagName("input");
    for (var i = 0; i < arrInputs.length; i++) {
        var oInput = arrInputs[i];
        if (oInput.type == "file") {
            var fileName = oInput.value;
            if (fileName.length > 0) {
                var valid = false;
                for (var j = 0; j < validFileExtensions.length; j++) {
                    var inputExtension = validFileExtensions[j];
                    if (fileName.substr(fileName.length - inputExtension.length, inputExtension.length).toLowerCase() == inputExtension.toLowerCase()) {
                        valid = true;
                        break;
                    }
                }
                if (!valid) {
                	document.getElementById("error").style.display="";
                	setTimeout(function(){ document.getElementById("error").style.display="none";}, 3000);
                    return false;
                }
            }
        }
    }
  
    return true;
}
</script>
<body>
    <div align="center">
         <form method="post" action="doUpload/widget-resources" onSubmit="return validateInput(this);" enctype="multipart/form-data">
            <table border="0">
                <tr>
                    <td>Pick file:</td>
                    <td><input type="file" name="fileUpload" size="50" /></td>
                </tr>
                <tr colspan="2">
                    <td><span  style="display:none;color:red" id="error">File must be zip.</span></td>
                    
                </tr>
                <tr>
                    <td colspan="2" align="center"><input type="submit" value="Upload" /></td>
                </tr>
            </table>
        </form>
    </div>
</body>
</html>