Laravel 5.7 getting images from storage - laravel

I have a little problem with getting an images from storage. Images are stored in storage/app/public/uploads/files directory. In database they are stored as file name image-1.png ... I am getting the files via url generated in Eloquent entity and url looks like src="/uploads/files/image-1.png" But cant see any image. Images are stored manually. Can somebody tell me please where is the problem?

If you generate the symbolic link, then your path will be :
/storage/uploads/files/image-1.png

Related

Laravel api call should return image url

I created a little API using Laravel, my doubt is where I should locate the images in the project and given a concrete API call how I return a URL to an image stored in my project?
You should return your image path like:
First things is retrieve/static located the images folder path in the project.And then retrieve name of image from database using query. Finally Concatenating name of image which is stored in DB.
http://yourSite.com/folderPath.$imageName
Because when upload images, We have added only name of images not full URL.

Laravel 5.6 file not found in storage

My Laravel application is about uploading and showing images. It was working good and all images where shown correctly. Now a few weeks later I tried to test it again and it stopped working. Images are in Laravel storage and path is correct but it says: "Failed to load resource: the server responded with a status of 404 (Not Found)".
Path is: http://localhost:8000/storage/images/8/uploaded/1536930406sunflower.png, and it's correct, image is there.
Weird is that it was working for months and now images cannot be found.
Thanks!
I have found the solution to my question and for those who have the same problem:
Storage link in public folder can be possibly broken.
1)Delete storage link in app/public folder.
2)Run command php artisan storage:link to create storage link again.
Also, you have to be sure about your upload folder name and database image addresses are the same.
Otherwise, it will broke and do not forget that it is case sensitive.Example: If image address is "jpg/photo1.jpg" on DB. Your upload folder in storage folder must be "jpg" not "JPG".

how and where can store images with laravel?

how and where I can store images using laravel?
context:
I want display some images in my main view (these are predefined by me).
I also want to store images uploaded by users, however, do not know where to store these images.
I'd like to call these from the view...
Thank you very much for the help. :)
Basically you can save your files wherever you want within your Laravel application provided that you have permissions to create directory and file.
But I prefer saving files in the storage/app folder. Laravel provides a simple API to manipulate files on disk. See the docs.
Update:
This answer was posted when Laravel was in version 5.2.
From version 5.3 on, you can easily create symbolic links by running the artisan command php artisan storage:link. See the docs.
Make directory for images in myapp/public/images and keep images on there.
<img src="{{URL('/images/logo.jpg')}}">
If you want to display them on your site store them in your public directory. Since they are uploaded by users you will need to pass them through a form. Here is an example of a controller.
$file = Input::file('picture');
$file->move(public_path().'/images/',$user->id.'.jpg');
The user will submit a form with a picture field. The two lines above will store it in the public directory in an images folder, with the relevant user's id as its name. Your probably best off making a model in your database for images and their paths. If you do, add these lines after the two above.
$image = new Image;
$image->path='/images/'.$user->id.'.jpg';
$image->user_id = $user->id;
$image->save();
To display it in the view simply set an $image variable to the correct image model in your controller and pass it to the view. Then pop its path in the src of the image.
<img src={{$image->path}} alt={{$image->path}}>

How to get relative URL path for an image uploaded on Oracle WebCenter

We are working on a requirement where we have to show a signature image on an RTF Template. This signature changes for one bank to other, so we are thinking to upload them in UCM server and use the URL's relative path concatenated with Bank Account ID/Number to fetch the image into RTF.
But, when we upload image by following Note 1605094.1 we are not able to get a relative path to hard code in our template file.
Uploaded one image (5486173210.gif), and the URL generated is as below
http://<ucmhost>:<ucmport>/cs/groups/public/documents/digitalmedia/ndg2/mtcz/~edisp/5486173210.gif
And the second image (11223344.gif) got the URL like below
http://<ucmhost>:<ucmport>/cs/groups/public/documents/digitalmedia/mdex/mjiz/~edisp/11223344.gif
We are looking for a common relative URL path, so that we can hard code that in our RTF Template.
URL something like below helps us.
http://<ucmhost>:<ucmport>/cs/groups/public/documents/digitalmedia/logos/5486173210.gif
http://<ucmhost>:<ucmport>/cs/groups/public/documents/digitalmedia/logos/11223344.gif
How about using the GET_FILE service URL?
http://<ucmhost>:<ucmport>/cs/idcplg?IdcService=GET_FILE&RevisionSelectionMethod=LatestReleased&allowInterrupt=1&dDocName=

Magento Image Url "_1.png" added to Image URL

On my website Magento adds _1 to the end of some Image urls.
So my normal basic urls should be ...media/catalog/product/cache/9/A/E/test-small.png
but somehow for some images it alters to ...media/catalog/product/cache/9/A/E/test3-small_1.png
My normal image names are unique numbers so I´m confused why this happens?
Could anyone help?
Magento will add a _1 after any image if the file already exists on the server.
Please mind that Magento is not doing cleaning of the images of products when / if you delete one product.
It is magento's by default feature, if the image name you are trying to upload already exist it will rename your current image name with _Number. Check before uploading.
Thanks
If anyone comes across this post using M2 and is having the same issue. Check out the media/tmp folder. I was working on an api image sync and the name kept having a _1, _2 etc after the image.
It turns out Magento doesn't always give a clear reason if something fails in the api so the file was making it to the tmp directory but never the final destination causing the file name issue.

Resources