I have a problem with my Angular4 app, I've made the whole upload file system and it's working but when i do upload the image and refresh the page, the image doesn"t change.
Here's the img tag
<img class="img-thumbnail img-responsive" src="../../../assets/img/profile/{{user.img}}" width="300px" height="300px">
user.img is a string from the database.
The component file
import { Component, OnInit } from '@angular/core';
import { FormControl,FormGroup,FormBuilder,Validators } from '@angular/forms';
import { AuthService } from '../../services/auth.service';
import { FileUploader ,FileSelectDirective} from 'ng2-file-upload';
@Component({
selector: 'app-edit-profile',
templateUrl: './edit-profile.component.html',
styleUrls: ['./edit-profile.component.css']
})
export class EditProfileComponent implements OnInit {
editForm;
messageClass;
message;
user;
birthday;
bYear; // cut the date to fit the select tag
bMonth;
bDay;
public uploader: FileUploader= new FileUploader({url:'http://localhost:8080/authentication/edit-photo',headers:[{name:'authorization',value:this.authService.authToken}]});
ngOnInit() {
this.authService.getProfile().subscribe(data=>{
this.user=data.user;
this.birthday=new Date(this.user.birthday);
this.bMonth=this.birthday.getUTCMonth() + 1;
this.bYear=this.birthday.getUTCFullYear();
this.bDay=this.birthday.getUTCDate();
});
I've tried lot of ways, none of them has worked yet. What do you propose ?
EDIT
I've noticed that when i saved the file in the code editor, the image changes, but after refreshing the browser, it's not.
I also want to specify that all image uploaded are placed in the asset folder in the src folder of angular, because i could'nt access them when they were outside of the angular directory. Maybe that's why it doesn't change before i save the file ? because the ng serve reload ? Please i need help for this