1234567891011121314151617181920212223242526 |
- <?php
- namespace App\Admin\Controllers\Api;
- use Encore\Admin\Controllers\AdminController;
- class ApiController extends AdminController
- {
- /**
- * 后台上传图片
- * @return string
- */
- public function upload()
- {
- $url = "error|服务器端错误";
- foreach (request()->file() as $file) {
- $url = "upload/images/".uniqid().rand(9000,100000).'.'.$file->getClientOriginalExtension();
- file_put_contents($url,file_get_contents($file->getRealPath()));
- }
- return env('APP_URL').'/'.$url;
- }
- }
|