Reputation: 125
public function index(){
$data = HeaderSlider::all();
return $data;
}
<ul *ngFor="let item of data">
<img [src]="item.image" />
</ul>
How to send (Laravel) image as link to frontend(angular) Where I store my image which sending like a response ? I try with storage in laravel but without success? I only want send link from server to frontend angular and in Angular bind src and print image. All my data from index function laravel come to frontend and all work property except image link ? Which folder in laravel is main for storage image? I try to search on google answer but I find only for request input type i don't want that.
Upvotes: 2
Views: 1073
Reputation: 21
if you are storing the image in laravel public directory. if the image available in public/images/beautifulNature.jpg. Then send /images/beautifulNature.jpg as the URL to the frontend and use in your html component something like this.
<img src="{{url('/images/beautifulNature.jpg')}}" alt="Image"/>
Upvotes: 1
Reputation: 104
create column as
if (!Schema::hasTable('file_attachment')) {
Schema::create('file_attachment', function (Blueprint $table) {
$table->increments('FileAttachmentID');
**$table->string('FileType')->nullable();
$table->string('FilePath')->nullable();
$table->integer('FileSourceID')->nullable();
$table->integer('SourceID')->nullable();**
//$table->dateTime('CreatedOn')->nullable();
$table->integer('CreatedBy')->nullable();
//$table->dateTime('ModifiedOn')->nullable();
$table->integer('updated_by')->nullable();
$table->timestamps();
});
}
in response send filepath in json.
Upvotes: 1
Reputation: 39
i'm also working on angular with laravel , best approach to is to concatenate full url in laravel query with image , like ,
Website Url where you will put your laravel api address
-------------------------------------------------------
HeaderSlider::CrossJoin('websiteurl')->select(DB::raw('CONCAT("websiteurl.base_url , headerslider.image") as image'))->get()
Upvotes: 1