简体   繁体   中英

How to save path to image in MYSQL

I have a table in my db with images, all images are stored on server side folder, so when I am saving an image, in url column I am writing path to its folder

INSERT INTO `images` SET `id` = "2", `url`="application/images/goat1.jpg", `album_id` = "1";

and then when I get this image to Angular side and trying to use this link as background url, I have an error, because url is undefined.

<div *ngFor="let photo of portfolioPreviewPhotos" class="previewPhoto" [style.backgroundImage]="'url('+ photo.link +')'"></div>

<div _ngcontent-c2="" class="previewPhoto" style="background-image: url(undefined;);">

So, can someone please explain to me how to properly write the path to the image in the database, if I want to store that image in php folder and then get it in Angular

Providing more info would be great, but to store the path it would be the same one when you write it down in url

so if

background-image: url("/app/images/someimage.png");

then in the database it should be url => "/app/images/someimage.png" or if the folder is static then on website

background-image: url("/app/images/'url from database'");

and in database ulr => 'someimage.png'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM