问题描述
尝试将 plupload 上传限制为某些文件类型。仅具有扩展名的过滤器是不够的,因为只需重命名文件扩展名即可。
例如,我们目前正在过滤以仅允许扩展名为“jpg、jpeg、gif、png”的图像文件。我遇到了一个问题,即用户尝试上传 file.jpg 但其 MIME 类型为“image/webp”。
我们还想强制使用有效的 MIME 类型。
我们目前的代码是这样的:
// Initialize the widget when the DOM is ready
$(function() {
$("#uploader").plupload({
// General settings
runtimes : 'html5,html4',url : "index.cfm?fa=Media.AddMedia",// Maximum file sizes
max_file_size : '1mb',chunk_size: '1mb',// Specify what files to browse for
filters : [
{title : "Image files",extensions : "jpg,jpeg,gif,png"}
],// Rename files by clicking on their titles
rename: true,// Sort files
sortable: true,// Enable ability to drag'n'drop files onto the widget (currently only HTML5 supports that)
dragdrop: true,// Views to activate
views: {
list: true,thumbs: true,// Show thumbs
active: 'thumbs'
}
});
$("#uploader").on("complete",function() {
window.parent.closePopWin();
});
});
我尝试按照 https://www.plupload.com/docs/v2/Options#filters.mime_types 中的内容添加 mime_types 过滤器,但似乎没有任何内容阻止无效的 mime 类型。
这可以完成还是我必须在服务器端进行验证??
重要提示:我们必须使用 Firefox 运行此网站!
谢谢一百万! 拍
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)