宝体数据调用接口
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

56 lines
1.1 KiB

<?php
namespace app\common\library\storage\engine;
/**
* 本地文件驱动
* Class Local
* @package app\common\library\storage\drivers
*/
class Local extends Server
{
public function __construct()
{
parent::__construct();
}
/**
* 上传图片文件
* @return array|bool
*/
public function upload()
{
// 上传目录
$uplodDir = WEB_PATH . 'uploads';
// 验证文件并上传
$info = $this->file->validate(['size' => 4 * 1024 * 1024, 'ext' => 'jpg,jpeg,png,gif'])
->move($uplodDir, $this->fileName);
if (empty($info)) {
$this->error = $this->file->getError();
return false;
}
return true;
}
/**
* 删除文件
* @param $fileName
* @return bool|mixed
*/
public function delete($fileName)
{
// 文件所在目录
$filePath = WEB_PATH . "uploads/{$fileName}";
return !file_exists($filePath) ?: unlink($filePath);
}
/**
* 返回文件路径
* @return mixed
*/
public function getFileName()
{
return $this->fileName;
}
}