Compare commits
3 Commits
a3a0ceef17
...
485d7c8d97
| Author | SHA1 | Date | |
|---|---|---|---|
| 485d7c8d97 | |||
| 97fa5ed432 | |||
| 33f1bdc729 |
3
.env
3
.env
@@ -66,8 +66,7 @@ static_root="/home/wwwroot/api.tmrjournals.com/public"
|
||||
[journal]
|
||||
;官网服务器地址
|
||||
base_url = http://journalapi.tmrjournals.com/public/index.php
|
||||
;base_url =http://192.168.110.131/journal/public/index.php
|
||||
journal_image_url = http://192.168.110.131/journal/public/
|
||||
journal_image_url = https://www.tmrjournals.com/public/
|
||||
|
||||
[gpt]
|
||||
api_key = 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
|
||||
|
||||
@@ -923,11 +923,21 @@ class Special extends Controller
|
||||
|
||||
/**
|
||||
* 上传文章的文件
|
||||
* coverLetter / picturesAndTables / manuscirpt 限制不超过 20M
|
||||
*/
|
||||
public function up_file($type)
|
||||
{
|
||||
$file = request()->file($type);
|
||||
if ($file) {
|
||||
$limitTypes = ['coverLetter', 'picturesAndTables', 'manuscirpt'];
|
||||
if (in_array($type, $limitTypes, true)) {
|
||||
$maxSize = 20 * 1024 * 1024;
|
||||
$fileInfo = $file->getInfo();
|
||||
$fileSize = isset($fileInfo['size']) ? intval($fileInfo['size']) : 0;
|
||||
if ($fileSize > $maxSize) {
|
||||
return json(['code' => 1, 'msg' => 'File size cannot exceed 20MB']);
|
||||
}
|
||||
}
|
||||
$info = $file->move(ROOT_PATH . 'public' . DS . $type);
|
||||
if ($info) {
|
||||
return json(['code' => 0, 'upurl' => str_replace("\\", "/", $info->getSaveName())]);
|
||||
@@ -1046,7 +1056,7 @@ class Special extends Controller
|
||||
$specials = isset($res['specials']) ? $res['specials'] : (isset($res['data']['specials']) ? $res['data']['specials'] : []);
|
||||
foreach ($specials as $k => $v) {
|
||||
unset($specials[$k]['abstract']);
|
||||
$specials[$k]['icon'] = $specials[$k]['icon']?$journal_image_url."specialIcon/".$specials[$k]['icon']:"";
|
||||
$specials[$k]['icon'] = $specials[$k]['icon']?$journal_image_url."journalicon/".$specials[$k]['icon']:"";
|
||||
}
|
||||
$re['specials'] = $specials;
|
||||
$re['count'] = isset($res['data']['count']) ? intval($res['data']['count']) : 0;
|
||||
@@ -2078,28 +2088,31 @@ class Special extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传专刊封面图(转发至 journal Special/up_icon_file)
|
||||
* 表单字段名:specialIcon
|
||||
* 上传专刊封面图(转发至 journal master/Journal/up_file)
|
||||
* 入参表单字段兼容 specialIcon / journalicon;转发官网时使用 journalicon
|
||||
*/
|
||||
public function up_icon_file()
|
||||
{
|
||||
$file = request()->file('specialIcon');
|
||||
if (!$file) {
|
||||
$file = request()->file('journalicon');
|
||||
}
|
||||
if (!$file) {
|
||||
return jsonError('specialIcon is required');
|
||||
}
|
||||
|
||||
$info = $file->getInfo();
|
||||
$tmpPath = isset($info['tmp_name']) ? $info['tmp_name'] : '';
|
||||
$originName = isset($info['name']) ? $info['name'] : 'specialIcon';
|
||||
$originName = isset($info['name']) ? $info['name'] : 'journalicon';
|
||||
$mime = isset($info['type']) && $info['type'] !== '' ? $info['type'] : 'application/octet-stream';
|
||||
if ($tmpPath === '' || !is_file($tmpPath)) {
|
||||
return jsonError('upload file invalid');
|
||||
}
|
||||
|
||||
$base_url = Env::get('journal.base_url');
|
||||
$url = rtrim($base_url, '/') . '/api/Special/up_icon_file';
|
||||
$url = rtrim($base_url, '/') . '/master/Journal/up_file';
|
||||
$postFields = [
|
||||
'specialIcon' => new \CURLFile(realpath($tmpPath), $mime, $originName),
|
||||
'journalicon' => new \CURLFile(realpath($tmpPath), $mime, $originName),
|
||||
];
|
||||
|
||||
$ch = curl_init($url);
|
||||
|
||||
Reference in New Issue
Block a user