上传的文件文件保留原名
This commit is contained in:
parent
67efa197ea
commit
7f8967d550
|
@ -43,7 +43,7 @@ steps:
|
||||||
password:
|
password:
|
||||||
from_secret: hub_password
|
from_secret: hub_password
|
||||||
repo: anxan-docker.pkg.coding.net/d/repo/micro-php-nacos
|
repo: anxan-docker.pkg.coding.net/d/repo/micro-php-nacos
|
||||||
tags: "0.0.8"
|
tags: "0.0.9"
|
||||||
|
|
||||||
- name: "完成通知"
|
- name: "完成通知"
|
||||||
image: anxan-docker.pkg.coding.net/d/repo/drone-email-notify:1.0
|
image: anxan-docker.pkg.coding.net/d/repo/drone-email-notify:1.0
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
-
|
-
|
||||||
- docker运行命令
|
- docker运行命令
|
||||||
```bash
|
```bash
|
||||||
docker run -d --name php-file-server -p 8000:80 -v /your/path:/var/www/html/public -e NACOS_ADDR=192.168.1.105:8848 -e SERVICE_PORT=8000 -e ORIGIN_URL=file.zeroerr.cn anxan-docker.pkg.coding.net/d/repo/micro-php-nacos:0.0.8
|
docker run -d --name php-file-server -p 8000:80 -v /your/path:/var/www/html/public -e NACOS_ADDR=192.168.1.105:8848 -e SERVICE_PORT=8000 -e ORIGIN_URL=file.zeroerr.cn anxan-docker.pkg.coding.net/d/repo/micro-php-nacos:0.0.9
|
||||||
```
|
```
|
||||||
- docker-compose.yml
|
- docker-compose.yml
|
||||||
```bash
|
```bash
|
||||||
|
@ -12,7 +12,7 @@ networks:
|
||||||
|
|
||||||
services:
|
services:
|
||||||
micro-php-nacos:
|
micro-php-nacos:
|
||||||
image: anxan-docker.pkg.coding.net/d/repo/micro-php-nacos:0.0.8
|
image: anxan-docker.pkg.coding.net/d/repo/micro-php-nacos:0.0.9
|
||||||
container_name: micro-php-nacos
|
container_name: micro-php-nacos
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
networks:
|
networks:
|
||||||
|
@ -37,6 +37,7 @@ services:
|
||||||
|`ORIGIN_URL`| 允许跨域的网址 |`{docker容器内ip}:8000`|-|
|
|`ORIGIN_URL`| 允许跨域的网址 |`{docker容器内ip}:8000`|-|
|
||||||
|`NAMESPACE_ID`| 要注册NACOS命名空间 |`0a1c32f2-dea1-4ec1-b546-cb4635cd7db2`|-|
|
|`NAMESPACE_ID`| 要注册NACOS命名空间 |`0a1c32f2-dea1-4ec1-b546-cb4635cd7db2`|-|
|
||||||
|`SERVICE_NAME`| 微服务名称 |`zeroerroa-file`|-|
|
|`SERVICE_NAME`| 微服务名称 |`zeroerroa-file`|-|
|
||||||
|
|`APP_DEBUG`| 是否开启调试模式 |`false`|-|
|
||||||
|
|
||||||
内部暴露的端口
|
内部暴露的端口
|
||||||
-
|
-
|
||||||
|
|
|
@ -32,8 +32,20 @@ class Index
|
||||||
// 允许跨域的域名
|
// 允许跨域的域名
|
||||||
$originUrl = $env->get('ORIGIN_URL', $serverIP . ':' . $servicePort);
|
$originUrl = $env->get('ORIGIN_URL', $serverIP . ':' . $servicePort);
|
||||||
|
|
||||||
|
// 获取文件原文件名
|
||||||
|
$trueName = $file->getOriginalName();
|
||||||
|
// 获取文件后缀名
|
||||||
|
$ext = $file->extension();
|
||||||
|
|
||||||
|
// 生成新文件名
|
||||||
|
$trueName = rtrim($trueName, ".$ext");
|
||||||
|
$fileName = $trueName . '_' . date('His') . '.' . $ext;
|
||||||
|
|
||||||
|
// 保存文件
|
||||||
|
// $file = $file->move(public_path() . 'uploads', $fileName);
|
||||||
|
|
||||||
// 组装保存路径
|
// 组装保存路径
|
||||||
$savename = \think\facade\Filesystem::disk('upload')->putFile('uploads', $file);
|
$savename = \think\facade\Filesystem::disk('upload')->putFileAs('uploads' . '/' . date('Ymd'), $file, $fileName);
|
||||||
$savename = str_replace('\\', '/', $savename);
|
$savename = str_replace('\\', '/', $savename);
|
||||||
|
|
||||||
return json([
|
return json([
|
||||||
|
|
Loading…
Reference in New Issue