如何解决Laravel上传的文件不在好文件夹中
这是我的代码:
Storage::disk('public')->putFileAs('/img/uploads/specialties',new File($validatedData['image_file']);
我的系统配置文件:
'public' => [
'driver' => 'local','root' => storage_path('app/public'),'url' => env('APP_URL').'/storage','visibility' => 'public',],
在本地模式下,当我上传图片时,它们会进入
/ public / storage / img / uploads / specialties
但是在生产中他们将要
/ storage / app / public / img / uploads / specialties
我尝试过的方法:$ php artisan storage:链接未成功。
任何人都知道如何更改上传文件在生产中的位置吗?
谢谢!
解决方法
我终于找到了解决方法:
const data = [
{ id: 1,name: 'A',referer_id: null,point: 4 },{ id: 2,name: 'B',referer_id: 1,point: 100 },{ id: 3,name: 'C',{ id: 4,name: 'D',point: 2 },{ id: 5,name: 'E',{ id: 6,name: 'F',{ id: 7,name: 'G',referer_id: 2,point: 4 }
];
const pointsByLevel = [1,0.5,0.3,0.2]; // NOTE: I added a 1.0 for level 0
function getPoint(user_id,level = 0) {
const user = data.find((u) => u.id === user_id);
const mainUserPoint = user.point;
let sum = 0;
for (let subdep of data.filter((d) => d.referer_id === user_id)) {
let val = getPoint(subdep.id,level + 1);
sum += val;
}
let result = (mainUserPoint * pointsByLevel[level]) + sum;
console.log(`getPoint for ${user_id} "${user.name}" is ${level} levels deep and has the value ${result}`)
return result;
}
console.log(getPoint(1));
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。