<script type="text/javascript"> var validFilesTypes = ["png", "jpg", "jpeg", "gif"];
function ValidateFile() { var file = document.getElementById("<%=FileUpload1.ClientID%>"); var filePath = file.value; var ext = filePath.substring(filePath.lastIndexOf(".") + 1, filePath.length).toLowerCase();
var isValidFile = false; for (var i = 0; i < validFilesTypes.length; i++) { if (ext == validFilesTypes[i]) { isValidFile = true; break; } }
if (!isValidFile) { alert("无效的文件。请上传文件扩展名为:/n/n" + validFilesTypes.join(", ")); }