1
This commit is contained in:
parent
87f691d2e8
commit
7a545ea88f
@ -165,23 +165,13 @@ $this->params['breadcrumbs'][] = $this->title;
|
|||||||
$json_de = json_decode($model->goodsHub->video_url, true);
|
$json_de = json_decode($model->goodsHub->video_url, true);
|
||||||
$temp_arr = [];
|
$temp_arr = [];
|
||||||
foreach ($json_de as $key => $val) {
|
foreach ($json_de as $key => $val) {
|
||||||
|
|
||||||
|
|
||||||
if($_SERVER['REMOTE_ADDR'] == '127.0.0.1'){
|
|
||||||
$val_model = filesize('D:/phpstudy_pro/WWW/cxgj/web' . $val);
|
|
||||||
}else{
|
|
||||||
$val_model = filesize($_SERVER["DOCUMENT_ROOT"] . $val);
|
|
||||||
}
|
|
||||||
|
|
||||||
$explode = explode('/', $val);
|
$explode = explode('/', $val);
|
||||||
$end = end($explode);
|
$end = end($explode);
|
||||||
//
|
//
|
||||||
$temp_arr[] = [
|
$temp_arr[] = [
|
||||||
'name' => $end,
|
'name' => $end,
|
||||||
'url' => $val,
|
'url' => $val,
|
||||||
'size_cn' => $val_model,
|
|
||||||
];
|
];
|
||||||
|
|
||||||
}
|
}
|
||||||
$model->goodsHub->video_url = json_encode($temp_arr, JSON_UNESCAPED_UNICODE);
|
$model->goodsHub->video_url = json_encode($temp_arr, JSON_UNESCAPED_UNICODE);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -103,18 +103,11 @@ $this->params['breadcrumbs'][] = $this->title;
|
|||||||
$temp_arr = [];
|
$temp_arr = [];
|
||||||
foreach ($json_de as $key => $val) {
|
foreach ($json_de as $key => $val) {
|
||||||
|
|
||||||
if ($_SERVER['REMOTE_ADDR'] == '127.0.0.1') {
|
|
||||||
$val_model = filesize('D:/phpstudy_pro/WWW/cxgj/web' . $val);
|
|
||||||
} else {
|
|
||||||
$val_model = filesize($_SERVER["DOCUMENT_ROOT"] . $val);
|
|
||||||
}
|
|
||||||
$explode = explode('/', $val);
|
$explode = explode('/', $val);
|
||||||
$end = end($explode);
|
$end = end($explode);
|
||||||
//
|
|
||||||
$temp_arr[] = [
|
$temp_arr[] = [
|
||||||
'name' => $end,
|
'name' => $end,
|
||||||
'url' => $val,
|
'url' => $val,
|
||||||
'size_cn' => $val_model,
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
$model->cover_pic = json_encode($temp_arr, JSON_UNESCAPED_UNICODE);
|
$model->cover_pic = json_encode($temp_arr, JSON_UNESCAPED_UNICODE);
|
||||||
|
|||||||
@ -12,12 +12,15 @@
|
|||||||
|
|
||||||
namespace app\modules\file\controllers;
|
namespace app\modules\file\controllers;
|
||||||
|
|
||||||
|
use app\components\Oss;
|
||||||
use Yii;
|
use Yii;
|
||||||
use app\modules\file\components\Uploader;
|
use app\modules\file\components\Uploader;
|
||||||
use app\modules\file\components\UploadHelper;
|
use app\modules\file\components\UploadHelper;
|
||||||
use app\models\file\UploadFile;
|
use app\models\file\UploadFile;
|
||||||
use app\models\Model;
|
use app\models\Model;
|
||||||
|
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
|
|
||||||
use Gumlet\ImageResize;
|
use Gumlet\ImageResize;
|
||||||
use Gumlet\ImageResizeException;
|
use Gumlet\ImageResizeException;
|
||||||
|
|
||||||
@ -365,8 +368,63 @@ class UploadController extends \app\controllers\Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//上传图片
|
// //上传图片
|
||||||
public function actionImage($rfmt = 'default')
|
// public function actionImage($rfmt = 'default')
|
||||||
|
// {
|
||||||
|
// if(!\Yii::$app->request->isPost){
|
||||||
|
// $data = [
|
||||||
|
// 'code' => 1,
|
||||||
|
// 'msg' => "Invalid Request"
|
||||||
|
// ];
|
||||||
|
// return $this->responseHandler($data);
|
||||||
|
// }
|
||||||
|
// $action = "uploadimage";
|
||||||
|
// $fileInfo = $this->uploadFile($action);
|
||||||
|
// if($rfmt == 'default'){
|
||||||
|
// if($fileInfo["state"] == "SUCCESS"){
|
||||||
|
// $data = [
|
||||||
|
// 'code' => 0,
|
||||||
|
// 'msg' => 'success',
|
||||||
|
// 'data' => [
|
||||||
|
// 'url' => $fileInfo['url'],
|
||||||
|
// 'extension' => $fileInfo["type"],
|
||||||
|
// 'size' => $fileInfo["size"],
|
||||||
|
// 'type' => $this->getFileType(trim($fileInfo['type'],"."))
|
||||||
|
// ]
|
||||||
|
// ];
|
||||||
|
// } else {
|
||||||
|
// $data = [
|
||||||
|
// 'code' => 1,
|
||||||
|
// 'msg' => $fileInfo["state"]
|
||||||
|
// ];
|
||||||
|
// }
|
||||||
|
// } else if($rfmt == 'wangeditor'){
|
||||||
|
// if($fileInfo["state"] == "SUCCESS"){
|
||||||
|
// $data = [
|
||||||
|
// 'errno' => 0,
|
||||||
|
// 'message' => 'success',
|
||||||
|
// 'data' => [
|
||||||
|
// 'url' => $fileInfo['url'],
|
||||||
|
// 'alt' => '',
|
||||||
|
// 'href' => '',
|
||||||
|
// 'extension' => $fileInfo["type"],
|
||||||
|
// 'size' => $fileInfo["size"],
|
||||||
|
// 'type' => $this->getFileType(trim($fileInfo['type'],"."))
|
||||||
|
// ]
|
||||||
|
// ];
|
||||||
|
// } else {
|
||||||
|
// $data = [
|
||||||
|
// 'errno' => 1,
|
||||||
|
// 'message' => $fileInfo["state"]
|
||||||
|
// ];
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return $this->responseHandler($data);
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
//上传图片到OSS
|
||||||
|
public function actionImage()
|
||||||
{
|
{
|
||||||
if (!\Yii::$app->request->isPost) {
|
if (!\Yii::$app->request->isPost) {
|
||||||
$data = [
|
$data = [
|
||||||
@ -375,50 +433,55 @@ class UploadController extends \app\controllers\Controller
|
|||||||
];
|
];
|
||||||
return $this->responseHandler($data);
|
return $this->responseHandler($data);
|
||||||
}
|
}
|
||||||
$action = "uploadimage";
|
|
||||||
$fileInfo = $this->uploadFile($action);
|
if (empty($_FILES['file']['name'])) {
|
||||||
if($rfmt == 'default'){
|
$data = [
|
||||||
if($fileInfo["state"] == "SUCCESS"){
|
'code' => 1,
|
||||||
|
'msg' => "请选择要上传的文件"
|
||||||
|
];
|
||||||
|
return $this->responseHandler($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 上传文件的目录
|
||||||
|
$upload_dir = "/web/uploads/1/";
|
||||||
|
|
||||||
|
if (!is_dir($upload_dir)) {
|
||||||
|
mkdir(\Yii::$app->basePath . '/web/upload/1', 0777, true);
|
||||||
|
}
|
||||||
|
$file = md5($_FILES['file']['name']);
|
||||||
|
// 上传文件的全名
|
||||||
|
$upload_file = \Yii::$app->basePath . '/web/upload/1/' . $file . '.png';
|
||||||
|
// 将上传的文件从临时目录移动到指定目录
|
||||||
|
if (!move_uploaded_file($_FILES['file']['tmp_name'], $upload_file)) {
|
||||||
|
$data = [
|
||||||
|
'code' => 1,
|
||||||
|
'msg' => "文件上传失败"
|
||||||
|
];
|
||||||
|
} else {
|
||||||
|
$oss = new Oss();
|
||||||
|
$file = '/web/upload/1/' . $file . '.png';
|
||||||
|
//上传文件目录
|
||||||
|
$oss_data = $oss->upload($upload_file, $file);
|
||||||
|
if ($oss == false) {
|
||||||
|
$data = [
|
||||||
|
'code' => 1,
|
||||||
|
'msg' => "文件上传失败"
|
||||||
|
];
|
||||||
|
} else {
|
||||||
$data = [
|
$data = [
|
||||||
'code' => 0,
|
'code' => 0,
|
||||||
'msg' => 'success',
|
'msg' => 'success',
|
||||||
'data' => [
|
'data' => [
|
||||||
'url' => $fileInfo['url'],
|
'url' => $oss_data,
|
||||||
'extension' => $fileInfo["type"],
|
|
||||||
'size' => $fileInfo["size"],
|
|
||||||
'type' => $this->getFileType(trim($fileInfo['type'],"."))
|
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
} else {
|
|
||||||
$data = [
|
|
||||||
'code' => 1,
|
|
||||||
'msg' => $fileInfo["state"]
|
|
||||||
];
|
|
||||||
}
|
|
||||||
} else if($rfmt == 'wangeditor'){
|
|
||||||
if($fileInfo["state"] == "SUCCESS"){
|
|
||||||
$data = [
|
|
||||||
'errno' => 0,
|
|
||||||
'message' => 'success',
|
|
||||||
'data' => [
|
|
||||||
'url' => $fileInfo['url'],
|
|
||||||
'alt' => '',
|
|
||||||
'href' => '',
|
|
||||||
'extension' => $fileInfo["type"],
|
|
||||||
'size' => $fileInfo["size"],
|
|
||||||
'type' => $this->getFileType(trim($fileInfo['type'],"."))
|
|
||||||
]
|
|
||||||
];
|
|
||||||
} else {
|
|
||||||
$data = [
|
|
||||||
'errno' => 1,
|
|
||||||
'message' => $fileInfo["state"]
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $this->responseHandler($data);
|
return $this->responseHandler($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//上传文件
|
//上传文件
|
||||||
public function actionFile($rfmt = 'default')
|
public function actionFile($rfmt = 'default')
|
||||||
{
|
{
|
||||||
@ -509,7 +572,8 @@ class UploadController extends \app\controllers\Controller
|
|||||||
* @TODO 扩展上传至第三方存储
|
* @TODO 扩展上传至第三方存储
|
||||||
* 文件上传
|
* 文件上传
|
||||||
*/
|
*/
|
||||||
private function uploadFile($action){
|
private function uploadFile($action)
|
||||||
|
{
|
||||||
//获取上传配置
|
//获取上传配置
|
||||||
$uploadConfig = $this->getUploadConfig($action);
|
$uploadConfig = $this->getUploadConfig($action);
|
||||||
$path = $uploadConfig["path"];
|
$path = $uploadConfig["path"];
|
||||||
@ -651,7 +715,8 @@ class UploadController extends \app\controllers\Controller
|
|||||||
/**
|
/**
|
||||||
* 获取已经上传的文件列表
|
* 获取已经上传的文件列表
|
||||||
*/
|
*/
|
||||||
private function getFileList($action){
|
private function getFileList($action)
|
||||||
|
{
|
||||||
//获取上传配置
|
//获取上传配置
|
||||||
$uploadConfig = $this->getUploadConfig($action);
|
$uploadConfig = $this->getUploadConfig($action);
|
||||||
$_path = $uploadConfig["path"];
|
$_path = $uploadConfig["path"];
|
||||||
@ -746,7 +811,8 @@ class UploadController extends \app\controllers\Controller
|
|||||||
/**
|
/**
|
||||||
* 获取上传路径前缀,及配置信息
|
* 获取上传路径前缀,及配置信息
|
||||||
*/
|
*/
|
||||||
private function getUploadConfig($action){
|
private function getUploadConfig($action)
|
||||||
|
{
|
||||||
|
|
||||||
$path = UploadHelper::getUploadPath();
|
$path = UploadHelper::getUploadPath();
|
||||||
$config = $this->uploadConfig['uploadFile'];
|
$config = $this->uploadConfig['uploadFile'];
|
||||||
@ -760,7 +826,8 @@ class UploadController extends \app\controllers\Controller
|
|||||||
/**
|
/**
|
||||||
* 抓取远程图片
|
* 抓取远程图片
|
||||||
*/
|
*/
|
||||||
private function crawlerImage($action) {
|
private function crawlerImage($action)
|
||||||
|
{
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
//获取上传配置
|
//获取上传配置
|
||||||
$uploadConfig = $this->getUploadConfig($action);
|
$uploadConfig = $this->getUploadConfig($action);
|
||||||
|
|||||||
@ -109,7 +109,7 @@ $this->registerJsFile($layui_js_file, ['depends' => 'app\modules\admin\assets\Ap
|
|||||||
<tr>
|
<tr>
|
||||||
<th>名称</th>
|
<th>名称</th>
|
||||||
<th>文件</th>
|
<th>文件</th>
|
||||||
<th>大小</th>
|
<!-- <th>大小</th>-->
|
||||||
<th>状态</th>
|
<th>状态</th>
|
||||||
<th style="width:188px">操作</th>
|
<th style="width:188px">操作</th>
|
||||||
</tr>
|
</tr>
|
||||||
@ -118,7 +118,7 @@ $this->registerJsFile($layui_js_file, ['depends' => 'app\modules\admin\assets\Ap
|
|||||||
<tr v-for="(item,index) in filelist">
|
<tr v-for="(item,index) in filelist">
|
||||||
<td>{{item.name}}</td>
|
<td>{{item.name}}</td>
|
||||||
<td>{{item.url}}</td>
|
<td>{{item.url}}</td>
|
||||||
<td>{{item.size_cn}}</td>
|
<!-- <td>{{item.size_cn}}</td>-->
|
||||||
<td>
|
<td>
|
||||||
<template v-if="item.status == 0">
|
<template v-if="item.status == 0">
|
||||||
<span class="layui-badge layui-bg-gray">待上传</span>
|
<span class="layui-badge layui-bg-gray">待上传</span>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user