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