Asp.net uses jquery to determine the size, type, and name of the File Uploaded By fileupload, and jqueryfileupload
1 <script language = "javascript" type = "text/javascript"> 2 // check the size of the uploaded file and obtain the file name. 3 function fileChange (target) {4 5 var fileSize = 0; 6 7 var filePath = target. value; 8 9 var fileSystem = new ActiveXObject ("Scripting. fileSystemObject "); 10 var file = fileSystem. getFile (filePath); 11 fileSize = file. size; 12 13 14 var size = fileSize/1024; 15 if (size> 10000) {16 alert ("attachment cannot exceed 10 M"); 17} 18 var arr = filePath. split ("\"); 19 if (target. id = "FileUpload1") {20 document. getElementById ('label8 '). innerHTML = size + "KB"; 21 22 23 $ ("# Label9" ).html (showDate (); LinkButton124 $ ("# LinkButton1" ).html (arr [arr. length-1]); 25} else {26 document. getElementById ('label10 '). innerHTML = size + "KB"; 27 28 $ ("# Label11" highlight .html (showDate (); 29 $ ("# LinkButton2" highlight .html (arr [arr. length-1]); 30} 31 32} 33 </script>
1 <tr id = "trrow6" runat = "server"> 2 <td colspan = "4" style = "background-color: # C0C0C0"> 3 <asp: label runat = "server" Text = "Upload attachment" Width = "301px"> </asp: label> 4 </td> 5 </tr> 6 7 <tr> 8 <td class = "left" style = "width: 167px "> 9 attachment </td> 11 <td> 12 <asp: FileUpload ID =" FileUpload1 "onchange =" fileChange (this) "runat =" server "Width =" 181px "style =" display: none "/> 13 <input id =" Button3 "type =" button "value =" Upload attachment "onclick =" document. getElementById ('fileupload1 '). click (); "/> 14 15 <asp: linkButton ID = "LinkButton1" runat = "server" CausesValidation = "false" CommandName = "download" 16 Text = ''onclick = "linkbutton#click"> </asp: linkButton> 17 <asp: Label ID = "Label14" runat = "server" Text = "" Visible = "false"> </asp: label> 18 </td> 19 <td> <asp: Label ID = "Label8" runat = "server"> </asp: label> </td> 20 <td> <asp: Label ID = "Label9" runat = "server"> </asp: label> </td> 21 </tr> 22 <tr> 23 <td class = "left" style = "width: 167px "> 24 attachments </td> 26 <td> 27 28 <asp: FileUpload ID =" FileUpload2 "runat =" server "29 onchange =" fileChange (this) "Width =" 179px "30 style =" display: none "31/> 32 <input id =" Button2 "type =" button "value =" Upload attachment "onclick =" document. getElementById ('fileupload2 '). click (); "/> 33 <asp: linkButton ID = "LinkButton2" runat = "server" CausesValidation = "false" CommandName = "download" 34 Text = ''onclick = "linkbutton#click"> </asp: linkButton> 35 <asp: Label ID = "Label26" runat = "server" Text = "" Visible = "true"> </asp: label> 36 <a title = "test"> </a> 37 </td> 38 <td> <asp: label ID = "Label10" runat = "server"> </asp: Label> </td> 39 <td> <asp: label ID = "Label11" runat = "server"> </asp: Label> </td> 40 </tr>