jQuery File Upload 的基本使用

來源:互聯網
上載者:User

標籤:

jQuery File Upload 是一個Jquery圖片上傳組件,支援多檔案上傳、取消、刪除,上傳前縮圖預覽、列表顯示圖片大小,支援上傳進度條顯示;支援各種動態語言開發的伺服器端。

一、最少配置

<!DOCTYPE HTML><html><head><meta charset="utf-8"><title>jQuery File Upload Example</title></head><body><input id="fileupload" type="file" name="files[]" data-url="server/php/" multiple><script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script><script src="js/vendor/jquery.ui.widget.js"></script><script src="js/jquery.iframe-transport.js"></script><script src="js/jquery.fileupload.js"></script><script>$(function () {    $(‘#fileupload‘).fileupload({        dataType: ‘json‘,        done: function (e, data) {            $.each(data.result.files, function (index, file) {                $(‘<p/>‘).text(file.name).appendTo(document.body);            });        }    });});</script></body> </html>

二、上傳進度顯示

$(‘#fileupload‘).fileupload({    /* ... */    progressall: function (e, data) {        var progress = parseInt(data.loaded / data.total * 100, 10);        $(‘#progress .bar‘).css(            ‘width‘,            progress + ‘%‘        );    }});
<div id="progress">    <div class="bar" style="width: 0%;"></div></div> .bar {    height: 18px;    background: green;}

附上官網API地址:https://github.com/blueimp/jQuery-File-Upload/wiki/API

文檔地址:https://github.com/blueimp/jQuery-File-Upload/wiki/Basic-plugin 

jQuery File Upload 的基本使用

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.