1234567891011121314151617181920212223242526272829303132333435363738 |
- <?php
- namespace app\admin\controller;
- use Tinywan\Storage\Storage;
- class UploadFile extends BaseController
- {
- /**
- * Notes:上传图片
- * @return \support\Response
- * User: yym
- * Date: 2022/7/28
- */
- public function uploadFile()
- {
- $category = $this->request->post('category', '');
- Storage::config(null, true, $category);
- $upload = Storage::uploadFile();
- $data = array();
- $config = config('plugin.tinywan.storage.app.storage');
- if(count($upload) == 1)
- {
- $data['http_url'] = $upload[0]['url'];
- $data['root_url'] = str_replace($config[$config['default']]['domain'], '', $upload[0]['url']);
- $data['mime_type'] = $upload[0]['mime_type'];
- }
- if(count($upload) > 1)
- {
- foreach ($upload as $k => $row)
- {
- $data[$k]['url'] = $row['url'];
- $data[$k]['root_url'] = str_replace($config[$config['default']]['domain'], '', $row['url']);
- $data[$k]['name'] = $row['origin_name'];
- }
- }
- return json_success($data, '上传成功');
- }
- }
|