完成上传组件的开发

This commit is contained in:
2020-04-10 21:19:03 +08:00
parent 5629daa722
commit a5a9c12ad0
18 changed files with 385 additions and 145 deletions

View File

@@ -176,6 +176,28 @@ function format_bytes($size, $delimiter = '') {
}
/**
* 获取附件信息
* @param int $cover_id
* @param string $field
* @return 完整的数据 或者 指定的$field字段值
*/
function get_attach($id, $field = null) {
$basePath = request()->domain();
if (empty($id)) {
return $basePath . '/static/images/default.png';
}
$picture = \think\facade\Db::name('Attach')->where(array('id' => $id))->find();
if ($field == 'path') {
if (!empty($picture['url'])) {
$picture['path'] = $picture['url'] ? $$basePath . $picture['url'] : $$basePath . '/static/images/default.png';
} else {
$picture['path'] = $picture['path'] ? $$basePath . $picture['path'] : $$basePath . '/static/images/default.png';
}
}
return empty($field) ? $picture : $picture[$field];
}
/**
* 获取文档封面图片
* @param int $cover_id