一个基于jQuery file Upload插件的花哨的文件上传器插件,它将正常的文件输入转换为响应灵敏、移动友好的上传器界面,支持拖放、键盘交互、文件预览、分块文件上传等。麻省理工学院或LGPL双重许可。
1.在网页的头部加载主CSS文件“fancy_fil上传.CSS”。
- <link rel="stylesheet" href="fancy_fileupload.css">
2.在文档末尾加载文件上传插件的脚本和其他所需的JavaScript文件。
- <script src="//code.jquery.com/jquery.min.js"></script>
- <script src="jquery.ui.widget.js"></script>
- <script src="jquery.fileupload.js"></script>
- <script src="jquery.iframe-transport.js"></script>
- <script src="jquery.fancy-fileupload.js"></script>
3.在文件输入字段上调用插件并完成。您可以指定服务器接受的文件类型:
- <input id="demo" type="file" name="files" accept=".jpg, .png, image/jpeg, image/png" multiple>
- $('#demo').FancyFileUpload({
- params : {
- action : 'fileuploader'
- },
- maxfilesize : 1000000
- });
4.所有可能的插件选项,以自定义文件上传器。
- $('#demo').FancyFileUpload({
- // send data to this url
- 'url' : '',
- // key-value pairs to send to the server
- 'params' : {},
- // editable file name?
- 'edit' : true,
- // max file size
- 'maxfilesize' : -1,
- // a list of allowed file extensions
- 'accept' : null,
- // 'iec_windows', 'iec_formal', or 'si' to specify what units to use when displaying file sizes
- 'displayunits' : 'iec_windows',
- // adjust the final precision when displaying file sizes
- 'adjustprecision' : true,
- // the number of retries to perform before giving up
- 'retries' : 5,
- // the base delay, in milliseconds, to apply between retries
- 'retrydelay' : 500,
- // an object containing valid MediaRecorder options
- // https://developer.mozilla.org/en-US/docs/Web/API/MediaRecorder
- 'audiosettings' : {},
- // whether or not to display a toolbar button with a webcam icon for recording video directly via the web browser
- 'recordvideo' : false,
- // an object containing valid MediaRecorder options
- // https://developer.mozilla.org/en-US/docs/Web/API/MediaRecorder
- 'videosettings' : {},
- // A valid callback function that is called after the preview dialog appears. Useful for temporarily preventing unwanted UI interactions elsewhere.
- 'showpreview' : function(e, data, preview, previewclone) {
- // do something
- },
- // A valid callback function that is called after the preview dialog disappears.
- 'hidepreview' : function(e, data, preview, previewclone) {
- // do something
- },
- // A valid callback function that is called during initialization to allow for last second changes to the settings.
- // Useful for altering fileupload options on the fly.
- 'preinit' : null,
- // A valid callback function that is called at the end of initialization of each instance.
- 'postinit' : null,
- // called for each item after it has been added to the DOM
- 'added' : function(e, data) {
- // do something
- },
- // called whenever starting the upload
- 'startupload' : function(SubmitUpload, e, data){
- // do something
- }
- // called whenever progress is updated
- 'continueupload' : function(e, data) {
- // do something
- },
- // called whenever an upload has been cancelled
- 'uploadcancelled' : function(e, data) {
- // do something
- },
- // called whenever an upload has successfully completed
- 'uploadcompleted' : function(e, data) {
- // do something
- },
- // jQuery File Upload options
- 'fileupload' : {},
- // translation strings here
- 'langmap' : {}
- });
2022-03-24
2022-02-27
2021-05-18
2020-11-29
2020-04-19
2020-04-13
2020-04-12
2020-03-04
2019-10-03
2019-03-30
2019-02-01
2018-03-03
2018-02-18
2018-01-20
2017-10-10
2017-08-07
2017-08-04