gpt4 book ai didi

In a laravel application with angular, images are not shown(在有角度的laravel应用程序中,不会显示图像)

转载 作者:bug小助手 更新时间:2023-10-22 15:46:48 28 4
gpt4 key购买 nike



I have a project in laravel for an API that is on the api.mydomain.com, while the application in angular is on mydomain.com.
The application saves the uploaded images and then shows them, locally everything works correctly, while when I put it on the server (shared server with plesk) it no longer shows me the images I upload and returns a 404 error.
I've already tried running the

我在laravel中有一个API项目,它位于API.mydomain.com上,而angular中的应用程序位于mydomain.com上。该应用程序保存上载的图像,然后显示它们,本地一切正常,而当我将其放在服务器(带有plesk的共享服务器)上时,它不再显示我上载的图像并返回404错误。我已经试过运行


php artisan storage:link

command, but it doesn't create a folder inside public, but only a file without an extension, so I manually create the link with

命令,但它不会在public中创建文件夹,而是只创建一个没有扩展名的文件,所以我手动创建了链接


ln -s /path/to/laravel/storage/app/public /path/to/public/storage

and that's how it creates the link.
Everything is set correctly in my config file:

这就是它创建链接的方式。在我的配置文件中,一切都设置正确:


'disks' => [

'local' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'throw' => false,
],

'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
'throw' => false,
],

],
'links' => [
public_path('storage') => storage_path('app/public'),
],

The structure of publis folder is:

耻骨文件夹的结构为:



public/storage/app/public/upload/editor/kitsImage/filename.png



while the url leading to the file is:

而指向该文件的url是:



api.mydomains.com/storage/upload/editor/kitsImage/filename.png



how come it still doesn't work?

为什么它仍然不起作用?


更多回答

First, did you check if the file is correctly stored in public folder? If files are correctly store, did you confirm the URL path/format is correct corresponding to the saved image in the public folder?

首先,您是否检查了文件是否正确存储在公用文件夹中?如果文件存储正确,是否确认与公用文件夹中保存的图像相对应的URL路径/格式正确?

what is the structure of your public folder? What is the URL path of the stored image? (you can omit the domain name)

您的公用文件夹的结构是什么?存储图像的URL路径是什么?(您可以省略域名)

In your config, I can see s3 setup, was the image uploaded in s3 instead? A lot of information is missing. Try to update the question with information as detailed as you can.

在你的配置中,我可以看到s3的设置,图像是在s3中上传的吗?缺少很多信息。试着用尽可能详细的信息更新问题。

Put that in the question, not in comments. Also did you confirm that the image url corresponds where the image is stored in public folder?

把它放在问题中,而不是评论中。此外,您是否确认图像url与图像存储在公用文件夹中的位置相对应?

Can you access the image using api.mydomains.com/editor/kitsImage/filename.png ?

您可以使用api.mydomains.com/editor/kitsImage/filename.png访问图像吗?

优秀答案推荐

your filesystems.local.root should be:

您的filesystems.local.root应该是:


'root' => storage_path('app')`

not


'root' => storage_path('app/public')

also the structure of your public folder after linking should be:

链接后的公用文件夹的结构也应该是:


public/storage/upload/editor/kitsImage/filename.png

not


public/storage/app/public/upload/editor/kitsImage/filename.png

更多回答

I edited the config file and re-launched the command and it created the correct path, but now returns a 403 error

我编辑了配置文件并重新启动了命令,它创建了正确的路径,但现在返回403错误

I have changed the permissions and now it works, thank you.

我已经更改了权限,现在可以工作了,谢谢。

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com