mirror of
https://gitee.com/ulthon/ulthon_information.git
synced 2026-03-03 16:24:28 +08:00
新增导出面板,便于转载拷贝发布;
This commit is contained in:
@@ -4,6 +4,8 @@ namespace app\admin\controller;
|
||||
|
||||
use app\model\UploadFiles;
|
||||
use app\UploadFiles as AppUploadFiles;
|
||||
use League\Flysystem\Util\MimeType;
|
||||
use think\facade\App;
|
||||
use think\facade\View;
|
||||
use think\Request;
|
||||
|
||||
@@ -74,6 +76,39 @@ class File extends Common
|
||||
{
|
||||
return AppUploadFiles::saveBase64File($request->param('data'), $request->param('type'));
|
||||
}
|
||||
public function tempBase64Save(Request $request)
|
||||
{
|
||||
|
||||
$file_data = $request->param('data');
|
||||
if (strstr($file_data, ",")) {
|
||||
$file_data = explode(',', $file_data);
|
||||
$file_data = $file_data[1];
|
||||
}
|
||||
$file_data = base64_decode($file_data);
|
||||
|
||||
$mime_type = MimeType::detectByContent($file_data);
|
||||
$ext_name = array_search($mime_type, MimeType::getExtensionToMimeTypeMap());
|
||||
|
||||
$public_file_path = '/temp_img/' . uniqid() . '.' . $ext_name;
|
||||
|
||||
|
||||
|
||||
$temp_file = App::getRootPath() . 'public' . $public_file_path;
|
||||
|
||||
$dirname = dirname($temp_file);
|
||||
|
||||
if (!is_dir($dirname)) {
|
||||
mkdir($dirname, 0777, true);
|
||||
}
|
||||
|
||||
file_put_contents($temp_file, $file_data);
|
||||
|
||||
// TODO:将文件存入数据库并且删除过期文件
|
||||
|
||||
return json_message([
|
||||
'src' => $public_file_path
|
||||
]);
|
||||
}
|
||||
|
||||
public function clear($id)
|
||||
{
|
||||
|
||||
@@ -126,6 +126,14 @@ class Post extends Common
|
||||
return View::fetch();
|
||||
}
|
||||
|
||||
public function output($id)
|
||||
{
|
||||
$model_post = ModelPost::find($id);
|
||||
|
||||
View::assign('post', $model_post);
|
||||
return View::fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存更新的资源
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user