在webman-admin后台上传的图片地址格式为 http://0.0.0.0:8787/app/admin/upload/files/20260503/69f70f593299.jpeg
但在API需要返回给客户端用,不想显示/app/admin ,想要转成类似 http://0.0.0.0:8787/upload/files/20260503/69f70f593299.jpeg 要在哪里配置?
plugin\admin\app\controller\UploadController.php 找到上传类中的部分代码如下:
$relative_path = $relative_dir . '/' . bin2hex(pack('Nn',time(), random_int(1, 65535))) . ".$ext"; $full_path = $base_dir . $relative_path; $file_size = $file->getSize(); $file_name = $file->getUploadName(); $mime_type = $file->getUploadMimeType(); $file->move($full_path); $image_with = $image_height = 0; if ($img_info = getimagesize($full_path)) { [$image_with, $image_height] = $img_info; $mime_type = $img_info['mime']; } return [ 'url' => "/app/admin/$relative_path", #-----------这里可以尝试下修改 'name' => $file_name, 'realpath' => $full_path, 'size' => $file_size, 'mime_type' => $mime_type, 'image_with' => $image_with, 'image_height' => $image_height, 'ext' => $ext, ];
这个方法在类中被调用了几次,酌情修改
nginx里转发下
plugin\admin\app\controller\UploadController.php
找到上传类中的部分代码如下:
这个方法在类中被调用了几次,酌情修改
nginx里转发下