<!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" />
<title>無標題文檔</title>
<script type="text/javascript">
function my_check(filename){
window.alert("ok");
var index = filename.lastIndexOf(".");
var ext = filename.substr(index);
if(ext == ".jpg" || ext == ".png" || ext == ".gif"){
var obj = document.getElementById("form");
obj.innerHTML("<input type = "button" value = "上傳" />");
}
else{
document.write("非法圖片類型!");
}
}
</script>
</head>
<body>
<form id="form" method="post" enctype="multipart/form-data">
<input type="file" name="uploadFile" onchange="javascript:my_check(this.value);"/>
</form>
</body>
</html>
function my_check(filename){
window.alert("ok"); var index = filename.lastIndexOf(".");
var ext = filename.substr(index);
if(ext == ".jpg" || ext == ".png" || ext == ".gif"){
var obj = document.getElementById("form");
obj.innerHTML("");
}
else{
document.write("非法圖片類型!");
}
}