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 51 52 53 54 55 56 57 58 59 60 61 62
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript">
function getfile(){
document.getElementById("hiddenfile").click();
document.getElementById('selectedfile').value=document.getElementById('hiddenfile').value;
document.getElementById("selectedfile").focus();
check(document.getElementById('hiddenfile').value);
}
function check(ext) {
//var ext = document.getElementById('hiddenfile').value;
ext = ext.substring(ext.length-3,ext.length);
ext = ext.toLowerCase();
if(ext != 'xls') {
alert('You selected a .'+ext+
' file; please select a .jpg file instead!');
return false;
}else{
return true;
}
}
function simulateClick() {
var evt = document.createEvent("MouseEvents");
evt.initMouseEvent("click", true, true, window,
0, 0, 0, 0, 0, false, false, false, false, 0, null);
var cb = document.getElementById("checkbox");
var canceled = !cb.dispatchEvent(evt);
if(canceled) {
// A handler called preventDefault
alert("canceled");
} else {
// None of the handlers called preventDefault
alert("not canceled");
}
}
</script>
</head>
<body>
<input type="file" name="hiddenfile" id="hiddenfile" accept="image/gif" style="display:none" />
<input type="text" name="selectedfile" id="selectedfile" />
<input type="image" src="compass.gif" onclick="getfile()" />
</body>
</html> |
Partager