鉴于html5已经是主流,flash终究是快湮灭了。所以现在上传也从uploadify更换成了uploadifive了,价值5美刀。在上传的过程中经常需要限制上传文件的类型,就需要用到参数fileType,于是就看下了官方手册上的介绍,文档上的对fileType参数定义的类型是string,且不是必须参数。经过拷贝demo的代码,发现根本无效,任何文件类型还是能够被上传。结果耗时3小时15分钟,翻遍国内外技术网站,最终确认uploadifive的fileType参数是个BUG,官方文档也标错了。经过反复测试,要想实现文件格式限制效果,需要使用json类型数据进行配置,才能实现参数正常解析。
官方demo:
$(function() {
$('#file_upload').uploadifive({
'fileType' : 'image/*',
'uploadScript' : '/uploadifive.php'
});
});
正确方式:
$(function() {
$('#file_upload').uploadifive({
'fileType' : 'image|rar|docx',
'uploadScript' : '/uploadifive.php'
});
});
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有