替换上传路径

master
notte 2018-07-19 15:13:26 +08:00
parent 57f96b657c
commit 2b3a6f32b9
5 changed files with 8 additions and 24 deletions

View File

@ -1,10 +1,4 @@
<?php
/**
* admin模块共用控制器
* User: WispX
* Date: 2017/9/15
* Time: 15:32
*/
namespace app\admin\controller;
@ -25,10 +19,6 @@ class Common extends Controller
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/');
$this->admin = Db::name('user')->where('username', session('admin'))->find();
if(count($this->admin) > 0) {

View File

@ -1,11 +1,5 @@
<?php
/**
* 图片管理
* User: WispX
* Date: 2017/9/22
* Time: 15:26
* Link: http://gitee.com/wispx
*/
namespace app\admin\controller;
use think\Db;
@ -34,7 +28,7 @@ class Picture extends Common
$val['user_id'] = $this->getUserName($val['user_id']);
switch ($val['scheme_id']) {
case 1:
$url = "{$this->web['domain']}/pic/{$val['path']}"; break;
$url = "{$this->web['domain']}/{$val['path']}"; break;
case 2:
$url = "{$scheme['qiniu']['domain']}/{$val['path']}"; break;
case 3:

View File

@ -249,5 +249,5 @@ return [
'theme_path' => str_replace("\\", "/", APP_PATH . "index/view/theme"),
//文件上传路径
'file_path' => str_replace("\\", "/", ROOT_PATH . "public/pic"),
'file_path' => str_replace("\\", "/", ROOT_PATH . "public"),
];

View File

@ -50,17 +50,17 @@ class Index extends Common
private function localUpload($file)
{
if($file) {
$date = date('Ymd', 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);
$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']}/" . $date);
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(
1,
$info->getFilename(),
$file->getInfo('type'),
$info->getSize(),
$info->hash('sha1'),
str_replace("\\", "/", "{$this->user['id']}/{$date}/{$info->getSaveName()}"),
str_replace("\\", "/", "{$date}/{$info->getSaveName()}"),
$file_path
);
} else {

View File

@ -55,7 +55,7 @@ class User extends Common
foreach ($data as &$val) {
switch ($val['scheme_id']) {
case 1:
$val['url'] = "{$this->web['domain']}/pic/{$val['path']}"; break;
$val['url'] = "{$this->web['domain']}/{$val['path']}"; break;
case 2:
$val['url'] = "{$scheme['qiniu']['domain']}/{$val['path']}"; break;
case 3: