Initial commit
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user