Skip to content

Commit

Permalink
修复设置上传大小不起作用的BUG
Browse files Browse the repository at this point in the history
  • Loading branch information
helloxz committed Sep 2, 2019
1 parent 4513dee commit b1f1b93
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 11 deletions.
8 changes: 7 additions & 1 deletion application/controllers/Upload.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ public function __construct()
}
//通用上传设置
protected function config($upload_path = ''){
//获取上传限制
$limit = $this->query->get_limit();
$limit = json_decode($limit);

//最大上传大小
$max_size = $limit->max_size * 1024;
//设置上传路径
if($upload_path == ''){
$upload_path = $this->upload_path;
Expand All @@ -70,7 +76,7 @@ protected function config($upload_path = ''){
$config['upload_path'] = $upload_path;
$config['allowed_types'] = 'gif|jpg|jpeg|png|bmp|webp';
//$config['allowed_types'] = 'image/jpeg|image/png|image/gif|image/bmp|image/x-ms-bmp|image/webp';
$config['max_size'] = 5120;
$config['max_size'] = $max_size;
$config['file_ext_tolower'] = TRUE; //文件名转换为小写
$config['overwrite'] = TRUE; //覆盖同名文件
$config['encrypt_name'] = TRUE; //随机命名图片
Expand Down
8 changes: 8 additions & 0 deletions application/models/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -364,5 +364,13 @@ public function get_token($value){
$imginfo = $this->db->query($sql)->row();
return $imginfo;
}
//获取上传限制
public function get_limit(){
$sql = "SELECT `values` FROM img_options WHERE `name` = 'uplimit' LIMIT 1;";
$query = $this->db->query($sql);
//只获取一行
$row = $query->row();
return $row->values;
}
}
?>
6 changes: 6 additions & 0 deletions application/views/admin/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@
<p><a href = "//shang.qq.com/wpa/qunwpa?idkey=1994c352ea864ed09a00fd3cfb0f80c946850a70e98551736be69f4253f09136" rel = "nofollow" target = "_blank" title = "加入ImgURL交流群,和大家一起讨论。">341195621</a></p>
</div>
</div>
<div class="layui-col-lg3">
<div class = "analyze">
<h3><i class="fa fa-paypal"></i> 购买专业版</h3>
<p><a href = "https://dwz.ovh/9" rel = "nofollow" target = "_blank" title = "ImgURL Pro专业版,功能更加强大。">https://dwz.ovh/9</a></p>
</div>
</div>
</div>
</div>

Expand Down
13 changes: 6 additions & 7 deletions application/views/user/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,15 @@
<ul class="layui-nav" lay-filter="">
<li class="layui-nav-item"><a href="/home/multiple"><i class="layui-icon layui-icon-upload"></i> 多图上传</a></li>
<li class="layui-nav-item"><a href="/found"><i class="layui-icon layui-icon-search"></i> 探索发现</a></li>
<li class="layui-nav-item"><a href="/home/log"><i class="layui-icon layui-icon-notice"></i> 更新日志</a></li>
<li class="layui-nav-item"><a href="https://dwz.ovh/9" target="_blank" rel="nofollow"><i class="layui-icon layui-icon-rmb"></i> 购买专业版</a></li>
<li class="layui-nav-item">
<a href="https://dwz.ovh/imgurldoc" target = "_blank" rel = "nofollow"><i class="layui-icon">&#xe705;</i> 帮助文档</a>
<a href="javascript:;" target = "_blank" rel = "nofollow"><i class="layui-icon layui-icon-tabs"></i> 其它选项</a>
<dl class="layui-nav-child"> <!-- 二级菜单 -->
<dd><a href="https://www.xiaoz.me/doc/doc-imgurl/install" rel = "nofollow" target = "_blank">安装ImgURL</a></dd>
<dd><a href="https://www.xiaoz.me/doc/doc-imgurl/api" rel = "nofollow" target = "_blank">ImgURL API</a></dd>
</dl>
<dd><a href="https://dwz.ovh/imgurldoc" rel = "nofollow" target = "_blank">帮助文档</a></dd>
<dd><a href="/home/log" rel = "nofollow" target = "_blank">更新日志</a></dd>
<dd><a href="https://github.com/helloxz/imgurl" rel = "nofollow" target = "_blank">源码下载</a></dd>
</dl>
</li>
<li class="layui-nav-item"><a href="https://github.com/helloxz/imgurl" target = "_blank" rel = "nofollow"><i class="layui-icon">&#xe635;</i> 源码</a></li>
<li class="layui-nav-item"><a href="/page/use"><i class="layui-icon">&#xe60b;</i> 关于</a></li>
<!-- 简单判断用户是否登录 -->
<?php if((isset($_COOKIE['user'])) && (isset($_COOKIE['token']))){ ?>
<li class="layui-nav-item"><a href="/admin/index"><i class="layui-icon layui-icon-console"></i> 后台管理</a></li>
Expand Down
2 changes: 1 addition & 1 deletion data/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v2.3-20190606
v2.31-20190902
4 changes: 2 additions & 2 deletions static/embed.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ layui.use(['upload','form','element','layer','flow'], function(){
,accept:'file'
,acceptMime:'image/webp,image/jpeg,image/pjpeg,image/bmp,image/png,image/x-png,image/gif'
,exts: 'jpg|jpeg|png|gif|bmp|webp'
,size:5120
,size:10240
,before: function(obj){ //obj参数包含的信息,跟 choose回调完全一致,可参见上文。
layer.load(); //上传loading
}
Expand Down Expand Up @@ -88,7 +88,7 @@ layui.use(['upload','form','element','layer','flow'], function(){
,acceptMime:'image/webp,image/jpeg,image/pjpeg,image/bmp,image/png,image/x-png,image/gif'
,exts: 'jpg|jpeg|png|gif|bmp|webp'
,multiple:true
,size:5120
,size:10240
,number:5 //可同时上传数量
,before: function(obj){ //上传之前的回调
//清空显示区域
Expand Down

0 comments on commit b1f1b93

Please sign in to comment.