• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

miaoxing / file / 12535743563

27 Dec 2024 01:44AM UTC coverage: 82.667% (-2.3%) from 84.932%
12535743563

push

github

twinh
feat(file): 后台管理员都允许上传文件

0 of 2 new or added lines in 1 file covered. (0.0%)

62 of 75 relevant lines covered (82.67%)

20.13 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

57.14
/pages/api/admin/files/index.php
1
<?php
2

3
use Miaoxing\App\Middleware\CheckPagePermission;
4
use Miaoxing\File\Service\File;
5
use Miaoxing\Plugin\BasePage;
6
use Miaoxing\Plugin\Service\Upload;
7
use Wei\Req;
8

9
return new class extends BasePage {
5✔
10
    public function init()
11
    {
NEW
12
        parent::init();
×
NEW
13
        $this->removeMiddleware(CheckPagePermission::class);
×
14
    }
15
    public function post(Req $req)
16
    {
17
        $ret = Upload::save([
5✔
18
            'exts' => 'image' === $req['type'] ? Upload::getAllowedImageExts() : Upload::getAllowedExts(),
5✔
19
            'path' => File::generatePath(),
5✔
20
        ]);
5✔
21
        if ($ret->isErr()) {
5✔
22
            return $ret;
5✔
23
        }
24

25
        return File::saveLocal($ret['file'], [
×
26
            'origName' => $ret['name'],
×
27
            'size' => $ret['size'],
×
28
        ]);
×
29
    }
30
};
5✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc