鉴于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' }); });