我正在使用以下设置将plupload与我的ASP.NET MVC3应用程序集成:
var uploaderSettings = {
runtimes: "html5,silverlight,flash,html4",
browse_button: "browse-button",
container: "upload-ui",
drop_element: "drag-drop-area",
file_data_name: "file",
multiple_queues: true,
max_file_size: "10mb",
url: '@Url.Action("Index", "Upload")',
flash_swf_url: '@Url.Content("~/js/plupload/plupload.flash.swf")',
silverlight_xap_url: '@Url.Content("~/js/plupload.silverlight.xap")',
filters: [
{title: "Excel Files", extensions: "xls,xslx,csv"}
],
multipart: true,
urlstream_upload: true,
dragdrop: true,
multipart_params: {
token: "@AuthToken()"
}
};
使用<input type="file">
属性中的以下项(以逗号分隔)生成accept
的plupload:
application/vnd.ms-excel
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
text/csv
在Firefox 12.0中,它会忽略过滤器并允许选择任何文件类型。
在Chrome 21中,它不适用于所提到的文件扩展名,但如果我将过滤器更改为图像文件(jpg,png,gif),则会正确过滤“选择文件”对话框。
我在Chromium bug跟踪器上找到this issue,这似乎是相关的,但在2010年10月被标记为已修复。
如果我将运行时优先级切换为silverlight或flash在html5以上,它可以正常工作,但我不想这样做,因为我失去了拖放文件上传功能。
这仅仅是对accept属性的浏览器支持的限制,我做错了什么,或者它是plupload中的错误?
更新:它显示为known issue,归结为浏览器对mime类型过滤的支持。
答案 0 :(得分:4)
听起来这不是验证文件类型的好方法。
accept attribute in input file is not working
仅用于暗示操作系统过滤对话框中的文件类型。
当我使用PL上传时,我是基于扩展服务器端做的。
答案 1 :(得分:0)
filters: {
max_file_size: '100mb',
prevent_duplicates: true,
**mime_types:** [title : "Image files", extensions : "jpg,jpeg,gif,png"]
}