增加多媒体音视频,文件摘要上传文件后缀名验证
This commit is contained in:
@@ -5,6 +5,22 @@
|
||||
<title><spring:message code="${cfgName}"></spring:message></title>
|
||||
<script type="text/javascript">
|
||||
$(function(){
|
||||
|
||||
var sfd = $("#functionId").val();
|
||||
var fileType=[];
|
||||
if(sfd==28||sfd==630){
|
||||
fileType=["mp4","flv","asf","wmv","avi","mpeg","mov","dat","m4v","m4p","m4b","webm","ogv","wav","mp3"];
|
||||
}
|
||||
if(sfd==29||sfd==631){
|
||||
fileType=["mp4","flv","asf","wmv","avi","mpeg","mov","dat","m4v","m4p","m4b","webm","ogv"];
|
||||
}
|
||||
if(sfd==30||sfd==632){
|
||||
fileType=["bmp","jpg","tiff","raw","gif"];
|
||||
}
|
||||
if(sfd==31){
|
||||
fileType=["mp4","flv","asf","wmv","avi","mpeg","mov","dat","m4v","m4p","m4b","webm","ogv","wav","mp3"];
|
||||
}
|
||||
$("#fileNoteInfo").attr("title","<spring:message code='select_file'/>: "+fileType);
|
||||
switchIpType($("select[name$='ipType']"));
|
||||
areaControlInit();
|
||||
$("input[name='isAreaEffective']").on('change',function(){
|
||||
@@ -27,9 +43,11 @@ $(function(){
|
||||
});
|
||||
$("#uploadSrc,#srcFileInfo").on('click',function(){
|
||||
$("#srcFile").trigger("click");
|
||||
|
||||
});
|
||||
|
||||
$("#srcFile").on('change',function(){
|
||||
sampleFileValidate(fileType,$("#srcFile").val());
|
||||
$("#srcFileInfo").val($("#srcFile").val());
|
||||
var videoToPicture = $("#videoToPicture").val();
|
||||
if(videoToPicture=="true"){
|
||||
@@ -103,6 +121,13 @@ $(function(){
|
||||
$("#cfgFrom").validate({
|
||||
submitHandler: function(form){
|
||||
var srcFile = $("#srcFile").val();
|
||||
|
||||
if(srcFile!=''){
|
||||
if(!sampleFileValidate(fileType,srcFile)){
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
//var sampleFile = $("#sampleFile").val();
|
||||
var srcUrl = $("#srcUrl").val();
|
||||
var srcPath = $("#srcPath").val();
|
||||
@@ -160,6 +185,32 @@ function hiddenlevel(){
|
||||
$("select[name='level']").selectpicker("refresh");
|
||||
}
|
||||
}
|
||||
|
||||
// 校验文件后缀名
|
||||
function sampleFileValidate(fileType,fileName){
|
||||
|
||||
var flag=false; //状态,检测文件后缀用
|
||||
var arr=fileType;//使用是什么格式的后缀
|
||||
var cFile=fileName;//文件的值
|
||||
//取出上传文件的扩展名
|
||||
var index=cFile.lastIndexOf(".");
|
||||
var ext = cFile.substr(index+1).toLowerCase();
|
||||
//循环比较
|
||||
for(var i=0;i<arr.length;i++){
|
||||
if(ext == arr[i]){
|
||||
flag = true; //一旦找到合适的,立即退出循环
|
||||
break;
|
||||
}
|
||||
}
|
||||
//条件判断
|
||||
$("#fileErrorNote").empty();
|
||||
if(!flag){
|
||||
// ("文件名不合法");
|
||||
$("#fileErrorNote").append("<label id='level-error' class='error'><spring:message code='file_in_wrong_format'/></label>");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
@@ -276,7 +327,10 @@ function hiddenlevel(){
|
||||
</c:otherwise>
|
||||
</c:choose>
|
||||
</div>
|
||||
<span id="fileNoteInfo" title="<spring:message code="select_file"/>"
|
||||
class="fileNoteInfo" data-icon="" style="cursor:default"> <spring:message code="info"/></span>
|
||||
<div for="srcFileInfo"></div>
|
||||
<div id="fileErrorNote"></div>
|
||||
</div>
|
||||
</div>
|
||||
<%-- <div class="col-md-6">
|
||||
|
||||
@@ -5,11 +5,15 @@
|
||||
<title><spring:message code="${cfgName}"></spring:message></title>
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
var fileType=["txt","doc","img","docx","pptx","xlsx","xls","ppt","mp4","flv","asf","wmv","avi","mpeg","mov","dat","m4v","m4p","m4b","webm","ogv","wav","mp3"];//使用是什么格式的后缀
|
||||
$("#fileNoteInfo").attr("title","<spring:message code='select_file'/>: "+fileType);
|
||||
$("#uploadSrc,#fileInfo").on('click', function() {
|
||||
$("#file").trigger("click");
|
||||
});
|
||||
$("#file").on('change', function() {
|
||||
$("#fileInfo").val($("#file").val());
|
||||
sampleFileValidate();
|
||||
|
||||
});
|
||||
hiddenlevel();
|
||||
$(".action").on("change", function() {
|
||||
@@ -28,6 +32,12 @@
|
||||
}
|
||||
},
|
||||
submitHandler : function(form) {
|
||||
if($("#file").val()!=''){
|
||||
if(!sampleFileValidate()){
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
var flag = true;
|
||||
//代表所有业务都隐藏了,提示必须增加一种业务数据
|
||||
/* if($(".boxSolid").length ==$(".boxSolid.hidden").length){
|
||||
@@ -71,7 +81,6 @@
|
||||
}else{
|
||||
return;
|
||||
}
|
||||
|
||||
},
|
||||
errorContainer : "#messageBox",
|
||||
errorPlacement : function(error, element) {
|
||||
@@ -108,6 +117,31 @@
|
||||
$("select[name='cfdsLevel']").selectpicker("refresh");
|
||||
}
|
||||
}
|
||||
// 校验文件后缀名
|
||||
function sampleFileValidate(){
|
||||
|
||||
var flag=false; //状态,检测文件后缀用
|
||||
var arr=["txt","doc","img","docx","pptx","xlsx","xls","ppt","mp4","flv","asf","wmv","avi","mpeg","mov","dat","m4v","m4p","m4b","webm","ogv","wav","mp3"];//使用是什么格式的后缀
|
||||
var cFile=$("#file").val();//文件的值
|
||||
//取出上传文件的扩展名
|
||||
var index=cFile.lastIndexOf(".");
|
||||
var ext = cFile.substr(index+1).toLowerCase();
|
||||
//循环比较
|
||||
for(var i=0;i<arr.length;i++){
|
||||
if(ext == arr[i]){
|
||||
flag = true; //一旦找到合适的,立即退出循环
|
||||
break;
|
||||
}
|
||||
}
|
||||
//条件判断
|
||||
$("#fileErrorNote").empty();
|
||||
if(!flag){
|
||||
// ("文件名不合法");
|
||||
$("#fileErrorNote").append("<label id='level-error' class='error'><spring:message code='file_in_wrong_format'/></label>");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
@@ -218,7 +252,10 @@
|
||||
<input id="rawLen" name="rawLen" type="hidden"
|
||||
value="${_cfg.rawLen }" />
|
||||
</div>
|
||||
<div for="fileInfo"></div>
|
||||
<span id="fileNoteInfo" title="<spring:message code="select_file"/>"
|
||||
class="fileNoteInfo" data-icon="" style="cursor:default"> <spring:message code="info"/></span>
|
||||
<div for="fileInfo"></div>
|
||||
<div id="fileErrorNote"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6 leveL" >
|
||||
|
||||
Reference in New Issue
Block a user