Files
usedcar/app/mzl/modules/upload/service/LocalService.php
T

33 lines
785 B
PHP
Raw Normal View History

2025-05-14 13:19:23 +08:00
<?php
namespace app\mzl\modules\upload\service;
use support\Request;
class LocalService
{
public function __construct()
{
}
/**
* 上传文件
*/
public function upload($file, $path = '', $type = 'excel')
{
// $file = $request->file('file');
if ($file && $file->isValid()) {
$pathUrl = $path == '' ? '/uploads/'.$type.'/'.date('Ymd').'/'.md5($file->getUploadName().time()).'.'.$file->getUploadExtension() : $path;
$fullPathUrl = public_path().$pathUrl;
$file->move($fullPathUrl);
$data = [
'file_url' => $pathUrl,
'full_url' => getenv('MAIN_DOMAIN').$pathUrl
];
return $data;
}
return false;
}
}