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.
46 lines
1.3 KiB
46 lines
1.3 KiB
<?php
|
|
/**
|
|
* raingad IM [ThinkPHP6]
|
|
* @author xiekunyu <raingad@foxmail.com>
|
|
*/
|
|
namespace app\enterprise\model;
|
|
|
|
use app\BaseModel;
|
|
class File extends BaseModel
|
|
{
|
|
protected $pk="file_id";
|
|
|
|
// 同步彻底删除文件
|
|
public static function syncDelFile($file_id)
|
|
{
|
|
if ($file_id) {
|
|
$file = new self();
|
|
$item = $file->where('file_id', $file_id)->find();
|
|
if ($item) {
|
|
// 删除文件
|
|
$filename_dir = root_path();
|
|
$file_path = $filename_dir . 'public/' . ltrim($item->src,'/');
|
|
if (file_exists($file_path)) {
|
|
unlink($file_path);
|
|
}
|
|
|
|
// 删除图片
|
|
$compress_img = $item->compress_img;
|
|
if ($compress_img) {
|
|
$img_path = $filename_dir . 'public/' . ltrim($compress_img,'/');
|
|
if (file_exists($img_path)) {
|
|
unlink($img_path);
|
|
}
|
|
}
|
|
|
|
// 删除图片数据
|
|
$item->delete();
|
|
}
|
|
// 同步删除表情包
|
|
$Emoji = Emoji::where('file_id', $file_id)->find();
|
|
if ($Emoji) {
|
|
$Emoji->delete();
|
|
}
|
|
}
|
|
}
|
|
}
|