diff --git a/app/admin/controller/Files.php b/app/admin/controller/Files.php index a7eed13..8fa8d93 100644 --- a/app/admin/controller/Files.php +++ b/app/admin/controller/Files.php @@ -27,6 +27,10 @@ class Files extends AuthController case 1: $savename = Filesystem::putFile('images', $file); $filePath = "/uploads/" . $savename; + //转换因为win导致的兼容问题 + if(strtoupper(substr(PHP_OS,0,3))==='WIN'){ + $filePath = str_replace( DIRECTORY_SEPARATOR, '/',$filePath); + } break; case 2: $savename = Filesystem::putFile('images', $file); @@ -53,6 +57,10 @@ class Files extends AuthController $type = $result[2]; if (!file_exists($path)) mkdir($path, 0755, true); $savename = $path . md5(time()) . ".{$type}"; + //转换因为win导致的兼容问题 + if(strtoupper(substr(PHP_OS,0,3))==='WIN'){ + $savename = str_replace( DIRECTORY_SEPARATOR, '/',$savename); + } if (file_put_contents($savename, base64_decode(str_replace($result[1], '', $data['image'])))) return app("json")->success("上传成功", ['src' => "/" . $savename]); else return app("json")->fail("上传失败,写入文件失败!"); } else return app("json")->fail("上传失败,图片格式有误!"); @@ -64,8 +72,11 @@ class Files extends AuthController */ public function tinymce() { - $savename = Filesystem::putFile('image', request()->file('file')); - return json_encode(['location' => "/uploads/" . $savename]); + $filePath = Filesystem::putFile('image', request()->file('file')); + if(strtoupper(substr(PHP_OS,0,3))==='WIN'){ + $filePath = str_replace( DIRECTORY_SEPARATOR, '/',$filePath); + } + return json_encode(['location' => "/uploads/" . $filePath]); } @@ -122,6 +133,10 @@ class Files extends AuthController ]])->check(['file' => $file]); $savename = Filesystem::putFile($type, $file); $filePath = "/uploads/" . $savename; + //转换因为win导致的兼容问题 + if(strtoupper(substr(PHP_OS,0,3))==='WIN'){ + $filePath = str_replace( DIRECTORY_SEPARATOR, '/',$filePath); + } return $savename ? app("json")->code()->success("上传成功", ['filePath' => $filePath, "name" => basename($savename)]) : app("json")->fail("上传失败"); } catch (ValidateException $e) { return app("json")->fail($e->getMessage()); diff --git a/app/admin/controller/Poster.php b/app/admin/controller/Poster.php index c1b55d8..ab897bd 100644 --- a/app/admin/controller/Poster.php +++ b/app/admin/controller/Poster.php @@ -74,7 +74,7 @@ class Poster extends AuthController $form = array(); $form[] = Elm::input('title', '广告名称')->col(10); $form[] = Elm::input('url', '链接地址')->col(10); - $form[] = Elm::frameImage('image', '广告图片', Url::buildUrl('admin/images/index', array('fodder' => 'image', 'limit' => 1)))->icon("ios-image")->width('96%')->height('440px')->col(10); + $form[] = Elm::frameImage('cover_path', '广告图片', Url::buildUrl('admin/images/index', array('fodder' => 'images', 'limit' => 1)))->icon("ios-image")->width('96%')->height('440px')->col(10); $form[] = Elm::input('sort', '排序')->col(10); $form[] = Elm::select('position', '位置')->options(function () { $options = []; @@ -102,7 +102,7 @@ class Poster extends AuthController $form = array(); $form[] = Elm::input('title', '广告名称', $ainfo['title'])->col(10); $form[] = Elm::input('url', '链接地址', $ainfo['url'])->col(10); - $form[] = Elm::frameImage('image', '广告图片', Url::buildUrl('admin/images/index', array('fodder' => 'image', 'limit' => 1)), $ainfo['image'])->icon("ios-image")->width('96%')->height('440px')->col(10); + $form[] = Elm::frameImage('cover_path', '广告图片', Url::buildUrl('admin/images/index', array('fodder' => 'images', 'limit' => 1)), $ainfo['cover_path'])->icon("ios-image")->width('96%')->height('440px')->col(10); $form[] = Elm::input('sort', '排序', $ainfo['sort'])->col(10); $form[] = Elm::select('position', '位置', $ainfo['position'])->options(function () { $options = []; @@ -128,13 +128,15 @@ class Poster extends AuthController ['id', ''], ['title', ''], ['url', ''], - ['image', ''], + ['cover_path', ''], + ['position', 0], ['sort', ''], ['status', 1], ]); if ($data['title'] == "") return app("json")->fail("广告名称不能为空"); if ($data['url'] == "") return app("json")->fail("链接地址不能为空"); - if (is_array($data['image'])) $data['image'] = $data['avatar'][0]; + if (is_array($data['cover_path'])) $data['cover_path'] = $data['cover_path'][0]; + $data['user_id'] = $this->adminId;//默认修改你 if ($id == "") { //判断下用户是否存在 $info = aModel::where('url', $data['url'])->find(); @@ -145,7 +147,7 @@ class Poster extends AuthController } else { $res = aModel::update($data, ['id' => $id]); } - cache(Data::DATA_ADVERT . '_' . $data['type'], null);//清除缓存 + cache(Data::DATA_ADVERT . '_' . $data['position'], null);//清除缓存 return $res ? app("json")->success("操作成功", 'code') : app("json")->fail("操作失败"); } } \ No newline at end of file diff --git a/app/admin/view/admin/profile.html b/app/admin/view/admin/profile.html index 7f256e4..1ae1855 100644 --- a/app/admin/view/admin/profile.html +++ b/app/admin/view/admin/profile.html @@ -114,23 +114,20 @@