[更新]增加文件上传插件案例

This commit is contained in:
Anyon 2017-07-10 19:17:07 +08:00
parent 441c660cf0
commit 3ddbb5419e
4 changed files with 119 additions and 2 deletions

View File

@ -0,0 +1,39 @@
<?php
// +----------------------------------------------------------------------
// | Think.Admin
// +----------------------------------------------------------------------
// | 版权所有 2014~2017 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://think.ctolog.com
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | github开源项目https://github.com/zoujingli/Think.Admin
// +----------------------------------------------------------------------
namespace app\demo\controller;
use controller\BasicAdmin;
/**
* 系统权限管理控制器
* Class Plugs
* @package app\demo\controller
* @author Anyon <zoujingli@qq.com>
* @date 2017/07/10 18:13
*/
class Inter extends BasicAdmin
{
/**
* 省市区插件
* @return \think\response\View
*/
public function file()
{
$this->title = '文件上传';
return view('', ['title' => $this->title]);
}
}

View File

@ -25,7 +25,6 @@ use controller\BasicAdmin;
*/
class Plugs extends BasicAdmin
{
public $title = '插件案例';
/**
* 省市区插件

View File

@ -0,0 +1,79 @@
{extend name='extra@admin/content'}
{block name="content"}
<div class="code">
<style>
.uploadbutton {
line-height: 50px;
display: inline-block;
position: absolute;
margin-left: 10px;
top: 20px;
}
</style>
<blockquote class="site-text layui-elem-quote">
单图片上传
</blockquote>
<div style="position:relative">
<div class="uploadimage">
<input type="hidden" name="file_1"/>
</div>
<a data-file="one"
data-field="file_1"
data-type="png,jpg"
data-uptype="local"
href="javascript:void(0)"
class="uploadbutton">上传图片</a>
</div>
<script>
require(['jquery'], function () {
$('[name="file_1"]').on('change', function () {
$(this).parent().css('backgroundImage', 'url(' + this.value + ')');
$(this).parent().attr('data-tips-image', this.value);
});
});
</script>
<pre class="layui-code" lay-title="HTML代码">
<div style="position:relative">
<div class="uploadimage">
<input type="hidden" name="file_1"/>
</div>
<a data-file="one"
data-field="file_1"
data-type="png,jpg"
data-uptype="local"
href="javascript:void(0)">上传图片</a>
</div>
</pre>
<pre class="layui-code" lay-title="javascript代码">
// 监听 input 的 onchange 事件
// 当有图片上传时,会触发 change 事件
require(['jquery'], function () {
$('[name="file_1"]').on('change', function () {
$(this).parent().css('backgroundImage', 'url(' + this.value + ')');
$(this).parent().attr('data-tips-image', this.value);
});
});
</pre>
<script>
require(['pcasunzips'], function () {
new PCAS('province', 'city', 'area', '广东省', '广州市', '海珠区');
});
</script>
</div>
<script>
layui.use('code', function () {
layui.code({
encode: true
});
});
</script>
{/block}

View File

@ -4,7 +4,7 @@
<div class="code">
<blockquote class="site-text layui-elem-quote">
PCAS 单文件JS省市区插件
PCAS 单文件JS省市区插件也适用于Wap端
</blockquote>
<div id="demo" class="citys">
<div class="layui-input-inline">