|
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
|
<Html xmlns = "http://www.w3.org/1999/xhtml"> |
|
<Head> |
|
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/> |
|
<Script src = "jquery-1.7.1.min.js" type = "text/javascript"> </script> |
|
<Script type = "text/javascript"> |
|
$ (Document). ready (function (){ |
|
|
|
$ ("# Form01"). change (function (){ |
|
|
|
Var filepath = $ ("input [name = 'myfile']"). val (); |
|
|
|
Var extStart = filepath. lastIndexOf ("."); |
|
|
|
Var ext = filepath. substring (extStart, filepath. length). toUpperCase (); |
|
|
|
If (ext! = ". BMP" & ext! = ". PNG" & ext! = ". GIF" & ext! = ". JPG" & ext! = ". JPEG "){ |
|
|
|
Alert ("images are limited to bmp, png, gif, jpeg, and jpg Formats "); |
|
Return false; |
|
} Else {$ ("# name01"). text (ext )} |
|
|
|
Var file_size = 0; |
|
If ($. browser. msie ){ |
|
Var img = new Image (); |
|
Img. src = filepath; |
|
While (true ){ |
|
If (img. fileSize> 0 ){ |
|
If (img. fileSize> 3*1024*1024 ){ |
|
|
|
Alert ("the image size is not greater than 100 MB. "); |
|
} Else { |
|
Var num03 = img. fileSize/1024; |
|
Num04 = num03.toFixed (2) |
|
$ (". Size02"). text (num04 + "KB "); |
|
} |
|
Break; |
|
} |
|
} |
|
} Else { |
|
File_size = this. files [0]. size; |
|
Console. log (file_size/1024/1024 + "MB "); |
|
|
|
Var size = file_size/1024; |
|
If (size & gt; 10240 ){ |
|
Alert ("the size of the uploaded file cannot exceed 10 MB! "); |
|
} Else { |
|
Var num01 = file_size/1024; |
|
Num02 = num01.toFixed (2) |
|
$ ("# Size01"). text (num02 + "KB "); |
|
} |
|
} |
|
Return true; |
|
}); |
|
|
|
}); |
|
</Script> |
|
<Title> untitled document </title> |
|
</Head> |
|
|
|
<Body> |
|
<Table width = "500" cellspacing = "0" cellpadding = "0"> |
|
<Tr> |
|
<Td width = "72" id = "name01"> & nbsp; </td> |
|
<Td width = "242"> <input type = "file" name = "myFile" id = "form01"/> </td> |
|
<Td width = "184" id = "size01" class = "size02"> & nbsp; </td> |
|
</Tr> |
|
</Table> |
|
|
|
</Body> |
|
</Html> |
|
|