Open malikghanim opened 9 months ago
I have this same problem, have you found any solution for this?
Same problem here, also need a solution to this. Showing when inspecting: http://localhost/uploads/http://localhost/uploads/images/image.png
In admin.php file: 'upload' => [
// Disk in `config/filesystem.php`.
'disk' => 'admin',
// Image and file upload path under the disk above.
'directory' => [
'image' => 'images',
'file' => 'files',
],
],
In filesystems.php file: 'disks' => [
'admin' => [
'driver' => 'local',
'root' => public_path('uploads'),
'url' => env('APP_URL').'/uploads',
'visibility' => 'public',
],
...
..
I have this same problem, have you found any solution for this?
anyone?
The problem occurs because the images path are saved with full path in the database.
I solved this problem changing the 'upload' default disk to 'public' in config/admin.php
file:
'upload' => [
// Disk in config/filesystem.php.
'disk' => 'public',
// Image and file upload path under the disk above.
'directory' => [
'image' => 'images',
'file' => 'files',
],
],
In config/filesystem.php
I setted the public
path this way:
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage', // set url
'visibility' => 'public',
'throw' => false,
],
This way the path is relative. This configuration worked for both localhost and live servers.
I implement this way in my Blade templates.
<img src="{{ asset('storage') . '/' . $image }}">
I have been doing some testing and I might have found a solution.
I have the default admin_users
table which has the avatar
field points to the image path.
I also have a products
table where the image
field points to the image path.
When editing one of these resources, the first one doesn't show a preview, whilst the second one does.
I have found a solution, its to add this line in /public/vendor/open-admin/fields/file-upload/file-upload.js
file in the method initPreview:
It seems that, for some reason, the first resource already has the full url appended. While the second resource I created myself does not. Likely due to the fact that the input itself has the full path added to it for the first resource, but not for the newly created one.
I haven't managed to research a level higher to see what the issue may be, but this seems to be a safe solution to this problem.
EDIT: I have made additional changes to this file to suit my particular usecase.
I installed open-admin by following the instructions step by step, Then I updated the config/filesystems.php and added the following :
I update user record from admin
http://localhost/admin/auth/users/1/edit
and upload new avatar imageThe Image is not showing, when I inspect the image I found that image url prefix duplicated as following
http://localhost/uploads/http://localhost/uploads/images/User_icon-cp.png
How to resolve that issue?