服务器文件上传
This commit is contained in:
@@ -52,13 +52,13 @@ class UploadedFilesService
|
||||
* 记录文件信息到数据库
|
||||
*
|
||||
* @param array $fileInfo 文件信息
|
||||
* @param Request $request 请求对象
|
||||
* @param Request|null $request 请求对象(可选)
|
||||
* @param string $partition 分区名称
|
||||
* @param string $category 文件分类
|
||||
* @return array
|
||||
* @throws BusinessException
|
||||
*/
|
||||
public function recordFileInfo(array $fileInfo, Request $request, string $partition = 'other', string $category = 'general'): array
|
||||
public function recordFileInfo(array $fileInfo, ?Request $request = null, string $partition = 'other', string $category = 'general'): array
|
||||
{
|
||||
|
||||
// 验证必需的文件信息
|
||||
@@ -73,6 +73,9 @@ class UploadedFilesService
|
||||
$fileExtension = pathinfo($fileInfo['file_name'], PATHINFO_EXTENSION);
|
||||
|
||||
// 记录到数据库
|
||||
$uploadIp = $request ? $request->getRealIp() : '0.0.0.0';
|
||||
$userAgent = $request ? $request->header('User-Agent', '') : '';
|
||||
|
||||
$fileData = [
|
||||
'file_name' => $fileInfo['file_name'],
|
||||
'file_path' => $fileInfo['file_path'],
|
||||
@@ -82,8 +85,8 @@ class UploadedFilesService
|
||||
'original_name' => $fileInfo['original_name'] ?? '',
|
||||
'extension' => $fileExtension,
|
||||
'partition' => $partition,
|
||||
'upload_ip' => $request->getRealIp(),
|
||||
'user_agent' => $request->header('User-Agent', ''),
|
||||
'upload_ip' => $uploadIp,
|
||||
'user_agent' => $userAgent,
|
||||
];
|
||||
|
||||
$uploadedFile = $this->logicCreate($fileData);
|
||||
|
||||
Reference in New Issue
Block a user