layui文件上傳實現(xiàn)代碼
更新時間:2017年05月20日 09:32:36 作者:廣信_劉東君
這篇文章主要為大家詳細介紹了layui導航欄效果的實現(xiàn)代碼,具有一定的參考價值,感興趣的小伙伴們可以參考一下
本文實例為大家分享了layui文件上傳的具體代碼,供大家參考,具體內(nèi)容如下
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>文件上傳</title>
<link rel="stylesheet" href="layui/css/layui.css">
<link rel="stylesheet" href="css/global.css">
</head>
<body>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
<legend>設(shè)定上傳文件的格式</legend>
</fieldset>
<input type="file" name="file" class="layui-upload-file">
<input type="file" name="file1" lay-type="file" class="layui-upload-file">
<input type="file" name="file1" lay-type="audio" class="layui-upload-file">
<input type="file" name="file2" lay-type="video" class="layui-upload-file">
<blockquote class="layui-elem-quote" style="margin-top: 20px;">支持拖動文件上傳</blockquote>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
<legend>演示上傳</legend>
</fieldset>
<div class="site-demo-upload">
<img id="LAY_demo_upload" src="layui/images/tong.jpg">
<div class="site-demo-upbar">
<input type="file" name="file" class="layui-upload-file" id="test">
</div>
</div>
<p style="margin-top: 20px;">注:由于服務器資源有限,所以此處每次給你返回的是同一張圖片</p>
<script src="layui/layui.js"></script>
<script>
layui.use('upload', function(){
layui.upload({
url: '' //上傳接口
,success: function(res){ //上傳成功后的回調(diào)
console.log(res)
}
});
layui.upload({
url: '/test/upload.json'
,elem: '#test' //指定原始元素,默認直接查找class="layui-upload-file"
,method: 'get' //上傳接口的http類型
,success: function(res){
LAY_demo_upload.src = res.url;
}
});
});
</script>
</body>
</html>
官網(wǎng)文件上傳

以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
jquery PrintArea 實現(xiàn)票據(jù)的套打功能(代碼)
下面小編就為大家?guī)硪黄猨query PrintArea 實現(xiàn)票據(jù)的套打功能(代碼)。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-03-03
jQuery.query.js 取參數(shù)的兩點問題分析
最近在項目中使用jQuery.query.js這個插件進行頁面間URL傳值,遇到如下兩點問題2012-08-08
jQuery插件zTree實現(xiàn)清空選中第一個節(jié)點所有子節(jié)點的方法
這篇文章主要介紹了jQuery插件zTree實現(xiàn)清空選中第一個節(jié)點所有子節(jié)點的方法,涉及jQuery樹形插件zTree針對節(jié)點的遍歷與移除相關(guān)操作技巧,需要的朋友可以參考下2017-03-03
Javascript中的異步編程規(guī)范Promises/A詳細介紹
這篇文章主要介紹了Javascript中的異步編程規(guī)范Promises/A詳細介紹,同時介紹了jQuery 中的 Deferred 和 Promises,需要的朋友可以參考下2014-06-06

