uploadify fileTypeDesc不起作用,大神指点
不知道为什么fileTypeDesc设置之后,如果我上传文件格式不符合规范,就会提示我
而不是按照我预期设置的提示,很苦恼的问题。
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%> <% String path = request.getContextPath(); %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Uploadify上传</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <link rel="stylesheet" href="uploadify/uploadify.css" type="text/css"></link> <script type="text/javascript" src="uploadify/jquery-1.7.2.min.js"></script> <script type="text/javascript" src="uploadify/jquery.uploadify-3.1.min.js"></script> <script type="text/javascript"> $(function() { $("#file_upload").uploadify({ 'height' : 27, 'width' : 80, 'buttonText' : '浏 览', 'swf' : '<%=path%>/uploadify/uploadify.swf', 'uploader' : '<%=path%>/servlet/UploadifySerlet', 'auto' : true, //当为true时,会自动上传 'fileSizeLimit' : '4000000KB', 'fileTypeDesc' : '请上传.jpg;*.png;*.gif;*.bmp;*.doc;*.txt',//允许上传的文件类型的描述,在弹出的文件选择框里会显示 'fileTypeExts' : '*.jpg;*.png;*.gif;*.bmp;*.doc;*.txt',//指定文件格式 'formData' : {'userName':'','qq':''}, 'onUploadStart' : function(file) { //校验 var name=$('#userName').val(); if(name.replace(/\s/g,'') == ''){ alert("名称不能为空!"); return false; } //校验 var qq=$('#qq').val(); if(qq.replace(/\s/g,'') == ''){ alert("QQ不能为空!"); return false; } $("#file_upload").uploadify("settings", "formData", {'userName':name,'qq':qq}); //$("#file_upload").uploadify("settings", "qq", ); } }); }); </script> </head> <body> <form action="" enctype="multipart/form-data"></form> 名称: <input type="text" id="userName" name="userName" value="admin"> <br> QQ: <input type="text" id="qq" name="qq" value="100000"> <br> <input type="file" name="uploadify" id="file_upload" /> <hr> <a href="javascript:$('#file_upload').uploadify('upload','*')">开始上传</a> <a href="javascript:$('#file_upload').uploadify('cancel', '*')">取消所有上传</a> </body> </html>
期待大牛解答~~
国士ˇ無双
10 years, 8 months ago