【发布时间】:2021-09-04 08:26:45
【问题描述】:
我在本地环境中使用 Laravel 7 创建了一个 Web 应用程序,它有一个选项,用户可以上传和更改他们的个人资料图片。
它在本地环境中运行良好。
最近我将此项目上传到子域下的实时服务器。我将所有公共文件放在子域文件夹中,将其他文件放在根目录中。
像这样。
File Structure
而现在当我跑步时
php artisan storage:link
它在 files/public/images 中上传图片 我需要图片到 hello.example.com/images
文件上传代码:
if ($request->hasFile('profile_image')) {
$image = $request->file('profile_image');
$name = time() . '.' . $image->getClientOriginalExtension();
$path = '/images/';
$destinationPath = public_path('images');
$image->move($destinationPath, $name);
$user_image = '';
if (isset($name)) {
$user_image = $path . $name;
}
}
【问题讨论】:
标签: php laravel image web file-upload