mirror of
https://gitee.com/ulthon/ulthon_information.git
synced 2026-03-04 00:24:29 +08:00
修复文件存储问题;增加文件上传;修复字段错误
This commit is contained in:
@@ -6,6 +6,9 @@ use app\model\TempImg;
|
||||
use app\model\UploadFiles;
|
||||
use app\UploadFiles as AppUploadFiles;
|
||||
use League\Flysystem\Util\MimeType;
|
||||
use League\MimeTypeDetection\FinfoMimeTypeDetector;
|
||||
use League\MimeTypeDetection\GeneratedExtensionToMimeTypeMap;
|
||||
use League\MimeTypeDetection\MimeTypeDetector;
|
||||
use think\facade\App;
|
||||
use think\facade\View;
|
||||
use think\Request;
|
||||
@@ -13,7 +16,7 @@ use think\Request;
|
||||
class File extends Common
|
||||
{
|
||||
/**
|
||||
* 显示资源列表
|
||||
* 显示资源列表.
|
||||
*
|
||||
* @return \think\Response
|
||||
*/
|
||||
@@ -30,8 +33,11 @@ class File extends Common
|
||||
$model_list->where('status', $status);
|
||||
}
|
||||
|
||||
$list = $model_list->paginate();
|
||||
$list = $model_list->paginate([
|
||||
'query' => $this->request->get(),
|
||||
]);
|
||||
View::assign('list', $list);
|
||||
View::assign('type', $type);
|
||||
|
||||
return View::fetch();
|
||||
}
|
||||
@@ -47,7 +53,7 @@ class File extends Common
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存新建的资源
|
||||
* 保存新建的资源.
|
||||
*
|
||||
* @param \think\Request $request
|
||||
* @return \think\Response
|
||||
@@ -63,6 +69,7 @@ class File extends Common
|
||||
{
|
||||
return AppUploadFiles::editormdSave($request);
|
||||
}
|
||||
|
||||
public function wangEditorSave(Request $request)
|
||||
{
|
||||
return AppUploadFiles::wangEditorSave($request);
|
||||
@@ -77,23 +84,23 @@ 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, ",")) {
|
||||
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());
|
||||
$mime_detector = new FinfoMimeTypeDetector();
|
||||
|
||||
$mime_type = $mime_detector->detectMimeTypeFromBuffer($file_data);
|
||||
$ext_name = array_search($mime_type, GeneratedExtensionToMimeTypeMap::MIME_TYPES_FOR_EXTENSIONS);
|
||||
|
||||
$public_file_path = '/temp_img/' . uniqid() . '.' . $ext_name;
|
||||
|
||||
|
||||
|
||||
$temp_file = App::getRootPath() . 'public' . $public_file_path;
|
||||
|
||||
$dirname = dirname($temp_file);
|
||||
@@ -105,12 +112,11 @@ class File extends Common
|
||||
file_put_contents($temp_file, $file_data);
|
||||
|
||||
$model_img = TempImg::create([
|
||||
'path' => $public_file_path
|
||||
'path' => $public_file_path,
|
||||
]);
|
||||
|
||||
|
||||
return json_message([
|
||||
'src' => $public_file_path
|
||||
'src' => $public_file_path,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -128,7 +134,7 @@ class File extends Common
|
||||
}
|
||||
|
||||
return json_message([
|
||||
'delete' => $list_img->count()
|
||||
'delete' => $list_img->count(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user