JS上传图片,须支持pdf格式文件解决方法
JS上传图片,须支持pdf格式文件
现有上传代码如下:(支持jpg,jpge,bmp,png格式上传),找个大大教下如何能成同时支持pdf上传的。谢谢。
$(function(){
$("#uploadAttach_file_uploader").uploadify({
"multi":true
,"swf":"/scmweb/Javascript/Upload/images/uploadify.swf"
,"buttonText":""
,"uploader":"/scmweb/Controls/Upload/FileUpload.aspx?ctlObj=uploadAttach_file_queue&IsCurr=False"
,"queueId":"uploadAttach_file_queue"
,"fileTypeDesc":"支持的格式:"
,"fileTypeExts":"*.jpg;*.jpge;*.bmp;*.pdf;*.png""//此处加上*.pdf;只是在上传选择文件中可以选择pdf格式,但无法上传文件。
,"fileObjName":"Files"
,"removeTimeout":1
,"fileSizeLimit":"20MB"//测试文件为339KB。
,"onSelectError": function(file,errorCode){ alert('the ifle '+ file.name + 'is too large');return false;}
,"onUploadSuccess": function(file,data,response) {
var tempName=data;//这句后加alert(tempName);当文件为图片格式时对话框为文件相关信息,pdf文件时对话框为0。
document.getElementById("uploadAttach_file_uploader_ul").innerHTML+=tempName;
}
,"onUploadError": function (file, errorCode, errorMsg, errorString) { }
});
});
请教下是什么问题,先谢谢各位了。
------解决方案--------------------
前台代码貌似没什么问题,检查下是不是后台过滤了文件类型。
现有上传代码如下:(支持jpg,jpge,bmp,png格式上传),找个大大教下如何能成同时支持pdf上传的。谢谢。
$(function(){
$("#uploadAttach_file_uploader").uploadify({
"multi":true
,"swf":"/scmweb/Javascript/Upload/images/uploadify.swf"
,"buttonText":""
,"uploader":"/scmweb/Controls/Upload/FileUpload.aspx?ctlObj=uploadAttach_file_queue&IsCurr=False"
,"queueId":"uploadAttach_file_queue"
,"fileTypeDesc":"支持的格式:"
,"fileTypeExts":"*.jpg;*.jpge;*.bmp;*.pdf;*.png""//此处加上*.pdf;只是在上传选择文件中可以选择pdf格式,但无法上传文件。
,"fileObjName":"Files"
,"removeTimeout":1
,"fileSizeLimit":"20MB"//测试文件为339KB。
,"onSelectError": function(file,errorCode){ alert('the ifle '+ file.name + 'is too large');return false;}
,"onUploadSuccess": function(file,data,response) {
var tempName=data;//这句后加alert(tempName);当文件为图片格式时对话框为文件相关信息,pdf文件时对话框为0。
document.getElementById("uploadAttach_file_uploader_ul").innerHTML+=tempName;
}
,"onUploadError": function (file, errorCode, errorMsg, errorString) { }
});
});
请教下是什么问题,先谢谢各位了。
------解决方案--------------------
前台代码貌似没什么问题,检查下是不是后台过滤了文件类型。