mirror of https://github.com/xinyewl/Simpic
替换上传路径
parent
57f96b657c
commit
2b3a6f32b9
|
@ -1,10 +1,4 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* admin模块共用控制器
|
|
||||||
* User: WispX
|
|
||||||
* Date: 2017/9/15
|
|
||||||
* Time: 15:32
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace app\admin\controller;
|
namespace app\admin\controller;
|
||||||
|
|
||||||
|
@ -25,10 +19,6 @@ class Common extends Controller
|
||||||
|
|
||||||
public function _initialize()
|
public function _initialize()
|
||||||
{
|
{
|
||||||
// 检测域名授权
|
|
||||||
// 不收费了。。
|
|
||||||
//$auth = json_decode(curl('https://service.lskys.cc/server.php', ['action' => 'auth', 'domain' => $_SERVER['HTTP_HOST']]), true);
|
|
||||||
//if(!$auth['code']) die('程序未授权,请联系QQ:<a href="http://wpa.qq.com/msgrd?v=3&uin=1591788658&site=qq&menu=yes">1591788658</a> 授权!');
|
|
||||||
if(empty(session('admin')) || empty(cookie('admin'))) return $this->redirect('login/');
|
if(empty(session('admin')) || empty(cookie('admin'))) return $this->redirect('login/');
|
||||||
$this->admin = Db::name('user')->where('username', session('admin'))->find();
|
$this->admin = Db::name('user')->where('username', session('admin'))->find();
|
||||||
if(count($this->admin) > 0) {
|
if(count($this->admin) > 0) {
|
||||||
|
|
|
@ -1,11 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* 图片管理
|
|
||||||
* User: WispX
|
|
||||||
* Date: 2017/9/22
|
|
||||||
* Time: 15:26
|
|
||||||
* Link: http://gitee.com/wispx
|
|
||||||
*/
|
|
||||||
namespace app\admin\controller;
|
namespace app\admin\controller;
|
||||||
|
|
||||||
use think\Db;
|
use think\Db;
|
||||||
|
@ -34,7 +28,7 @@ class Picture extends Common
|
||||||
$val['user_id'] = $this->getUserName($val['user_id']);
|
$val['user_id'] = $this->getUserName($val['user_id']);
|
||||||
switch ($val['scheme_id']) {
|
switch ($val['scheme_id']) {
|
||||||
case 1:
|
case 1:
|
||||||
$url = "{$this->web['domain']}/pic/{$val['path']}"; break;
|
$url = "{$this->web['domain']}/{$val['path']}"; break;
|
||||||
case 2:
|
case 2:
|
||||||
$url = "{$scheme['qiniu']['domain']}/{$val['path']}"; break;
|
$url = "{$scheme['qiniu']['domain']}/{$val['path']}"; break;
|
||||||
case 3:
|
case 3:
|
||||||
|
|
|
@ -249,5 +249,5 @@ return [
|
||||||
'theme_path' => str_replace("\\", "/", APP_PATH . "index/view/theme"),
|
'theme_path' => str_replace("\\", "/", APP_PATH . "index/view/theme"),
|
||||||
|
|
||||||
//文件上传路径
|
//文件上传路径
|
||||||
'file_path' => str_replace("\\", "/", ROOT_PATH . "public/pic"),
|
'file_path' => str_replace("\\", "/", ROOT_PATH . "public"),
|
||||||
];
|
];
|
||||||
|
|
|
@ -50,17 +50,17 @@ class Index extends Common
|
||||||
private function localUpload($file)
|
private function localUpload($file)
|
||||||
{
|
{
|
||||||
if($file) {
|
if($file) {
|
||||||
$date = date('Ymd', time());
|
$date = date('Y-m-d', time());
|
||||||
$info = $file->validate(['size'=> $this->conf['upload_max_filesize'] * 1024, 'ext'=> $this->conf['upload_images_ext']])->rule('uniqid')->move("{$this->conf['file_path']}/{$this->user['id']}/" . $date);
|
$info = $file->validate(['size'=> $this->conf['upload_max_filesize'] * 1024, 'ext'=> $this->conf['upload_images_ext']])->rule('uniqid')->move("{$this->conf['file_path']}/" . $date);
|
||||||
if($info) {
|
if($info) {
|
||||||
$file_path = str_replace("\\", "/", Config::get('web.domain') . "/pic/{$this->user['id']}/{$date}/{$info->getSaveName()}");
|
$file_path = str_replace("\\", "/", Config::get('web.domain') . "/{$date}/{$info->getSaveName()}");
|
||||||
return $this->saveImg(
|
return $this->saveImg(
|
||||||
1,
|
1,
|
||||||
$info->getFilename(),
|
$info->getFilename(),
|
||||||
$file->getInfo('type'),
|
$file->getInfo('type'),
|
||||||
$info->getSize(),
|
$info->getSize(),
|
||||||
$info->hash('sha1'),
|
$info->hash('sha1'),
|
||||||
str_replace("\\", "/", "{$this->user['id']}/{$date}/{$info->getSaveName()}"),
|
str_replace("\\", "/", "{$date}/{$info->getSaveName()}"),
|
||||||
$file_path
|
$file_path
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -55,7 +55,7 @@ class User extends Common
|
||||||
foreach ($data as &$val) {
|
foreach ($data as &$val) {
|
||||||
switch ($val['scheme_id']) {
|
switch ($val['scheme_id']) {
|
||||||
case 1:
|
case 1:
|
||||||
$val['url'] = "{$this->web['domain']}/pic/{$val['path']}"; break;
|
$val['url'] = "{$this->web['domain']}/{$val['path']}"; break;
|
||||||
case 2:
|
case 2:
|
||||||
$val['url'] = "{$scheme['qiniu']['domain']}/{$val['path']}"; break;
|
$val['url'] = "{$scheme['qiniu']['domain']}/{$val['path']}"; break;
|
||||||
case 3:
|
case 3:
|
||||||
|
|
Loading…
Reference in New Issue