jQuery Fancy响应文件上传器 FancyFileUpload

  • 源码大小:77.91KB
  • 所需积分:1积分
  • 源码编号:19JP-3654
  • 浏览次数:854次
  • 最后更新:2023年07月07日
  • 所属栏目:表单
我要下载
加入收藏
本站默认解压密码:19jp.com 或 19jp_com

简介

一个基于jQuery file Upload插件的花哨的文件上传器插件,它将正常的文件输入转换为响应灵敏、移动友好的上传器界面,支持拖放、键盘交互、文件预览、分块文件上传等。麻省理工学院或LGPL双重许可。

如何使用它:

1.在网页的头部加载主CSS文件“fancy_fil上传.CSS”。

  1. <link rel="stylesheet" href="fancy_fileupload.css">

2.在文档末尾加载文件上传插件的脚本和其他所需的JavaScript文件。

  1. <script src="//code.jquery.com/jquery.min.js"></script>
  2. <script src="jquery.ui.widget.js"></script>
  3. <script src="jquery.fileupload.js"></script>
  4. <script src="jquery.iframe-transport.js"></script>
  5. <script src="jquery.fancy-fileupload.js"></script>

3.在文件输入字段上调用插件并完成。您可以指定服务器接受的文件类型:

  1. <input id="demo" type="file" name="files" accept=".jpg, .png, image/jpeg, image/png" multiple>
  1. $('#demo').FancyFileUpload({
  2. params : {
  3. action : 'fileuploader'
  4. },
  5. maxfilesize : 1000000
  6. });

4.所有可能的插件选项,以自定义文件上传器。

  1. $('#demo').FancyFileUpload({
  2.  
  3. // send data to this url
  4. 'url' : '',
  5.  
  6. // key-value pairs to send to the server
  7. 'params' : {},
  8.  
  9. // editable file name?
  10. 'edit' : true,
  11.  
  12. // max file size
  13. 'maxfilesize' : -1,
  14.  
  15. // a list of allowed file extensions
  16. 'accept' : null,
  17.  
  18. // 'iec_windows', 'iec_formal', or 'si' to specify what units to use when displaying file sizes
  19. 'displayunits' : 'iec_windows',
  20.  
  21. // adjust the final precision when displaying file sizes
  22. 'adjustprecision' : true,
  23.  
  24. // the number of retries to perform before giving up
  25. 'retries' : 5,
  26.  
  27. // the base delay, in milliseconds, to apply between retries
  28. 'retrydelay' : 500,
  29.  
  30. // an object containing valid MediaRecorder options
  31. // https://developer.mozilla.org/en-US/docs/Web/API/MediaRecorder
  32. 'audiosettings' : {},
  33.  
  34. // whether or not to display a toolbar button with a webcam icon for recording video directly via the web browser
  35. 'recordvideo' : false,
  36.  
  37. // an object containing valid MediaRecorder options
  38. // https://developer.mozilla.org/en-US/docs/Web/API/MediaRecorder
  39. 'videosettings' : {},
  40.  
  41. // A valid callback function that is called after the preview dialog appears. Useful for temporarily preventing unwanted UI interactions elsewhere.
  42. 'showpreview' : function(e, data, preview, previewclone) {
  43. // do something
  44. },
  45.  
  46. // A valid callback function that is called after the preview dialog disappears.
  47. 'hidepreview' : function(e, data, preview, previewclone) {
  48. // do something
  49. },
  50.  
  51. // A valid callback function that is called during initialization to allow for last second changes to the settings.
  52. // Useful for altering fileupload options on the fly.
  53. 'preinit' : null,
  54.  
  55. // A valid callback function that is called at the end of initialization of each instance.
  56. 'postinit' : null,
  57.  
  58. // called for each item after it has been added to the DOM
  59. 'added' : function(e, data) {
  60. // do something
  61. },
  62.  
  63. // called whenever starting the upload
  64. 'startupload' : function(SubmitUpload, e, data){
  65. // do something
  66. }
  67.  
  68. // called whenever progress is updated
  69. 'continueupload' : function(e, data) {
  70. // do something
  71. },
  72.  
  73. // called whenever an upload has been cancelled
  74. 'uploadcancelled' : function(e, data) {
  75. // do something
  76. },
  77.  
  78. // called whenever an upload has successfully completed
  79. 'uploadcompleted' : function(e, data) {
  80. // do something
  81. },
  82.  
  83. // jQuery File Upload options
  84. 'fileupload' : {},
  85.  
  86. // translation strings here
  87. 'langmap' : {}
  88.  
  89. });

更新日志:

2022-03-24

  • 固定间距问题。

2022-02-27

  • 更新的文件上传器帮助程序

2021-05-18

  • 增加了德语翻译语言包。

2020-11-29

  • 已更新

2020-04-19

  • 修复了相同元素问题上的销毁/重新创建循环。

2020-04-13

  • 停止流跟踪以释放摄像头/麦克风访问权限。

2020-04-12

  • 更新的jQuery文件上传

2020-03-04

  • 添加了postinit选项。

2019-10-03

  • 已更新服务器端帮助程序。

2019-03-30

  • 修复了Edge中的语法错误问题。
  • 修复了FlexForms依赖关系问题。FlexForms模块中的Backported GetFileStartPosition()更改。

2019-02-01

  • 增加了对直接从麦克风和网络摄像头/摄像机录制的支持。

2018-03-03

  • 修复了DOM元素创建问题。

2018-02-18

  • 修复了缺少URL引用的问题。
  • 添加了服务器端帮助PHP类。

2018-01-20

  • 添加了预览对话框显示/隐藏回调。

2017-10-10

  • 添加了服务器端帮助PHP类。

2017-08-07

  • 改进了对分块上传的支持,并修复了各种错误。添加了预安装选项。

2017-08-04

  • 修复了上传前取消的问题。

预览截图