33 lines
785 B
PHP
33 lines
785 B
PHP
<?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;
|
|
}
|
|
} |