Laravel api call should return image url - laravel

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.

Related

Laravel 8 - Create a PDF file from a API return string data

In Laravel, I am trying to create a pdf file from an API response PDF data string. How can i create and save PDF in storage directory physically in Laravel.
Check the image below:
In this image i hit an API and got a response in variable data->labelDataPdf . I want to create a pdf file using this string value.
Try this package, it implements a popular PHP library (http://www.fpdf.org/) for pdf generation in Laravel

Laravel 5.7 getting images from storage

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

Relative Path for VueJS / Laravel does not work when accessing a specific nested page (Router History On)

So here's my question. I have a site blog site called www.blog.com which is the root URL.
I link my images like this.
Basically for root URL
URL: www.blog.com
Resource Path : public/img/blog-logo.png <img :src="public/img/blog-logo.png">
and for nested routes
URL: www.blog.com/blog/i-am-a-post
Resource Path : public/img/blog-logo.png. <img :src="public/img/blog-logo.png">
Which is fairly the same. and if I go to the main www.blog.com and navigate to www.blog.com/blog/i-am-a-postI am able to see the images okay. However, when I access directly www.blog.com/blog/i-am-a-post (i.e typing the URL) in the browser, my image path looks like this www.blog.com/blog/i-am-a-post/public/blog-logo.png. So my question how do you configure or handle image paths? When a user directly access a page?
I already have a solution for it by creating an image helper method i.e v-bind:src="assetURL + 'public/img/blog-logo.png'" where assetURL is dynamic in creating '../'depending on how nested the URL path is. But I want to know how you guys implement such a way. Thank you!
Are you using laravel+vue using laravel.mix? You can just call /img/blog-logo.png where img folder is inside your public folder.

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=

Resources