I am currently working on a form in Angular that is used to submit information such as author, context, and recently added images. However, I have run into an issue where I am able to successfully retrieve the author and context, but not the images (it always shows up as null).
=== Backend with SpringBoot === Model:
public class Content {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String context;
private String author;
private String images;
public Long getId() { return id; }
public String getContext() { return context; }
public String getAuthor() { return author; }
public String getImage() { return images; }
}
Controller:
@PostMapping("/create")
@ResponseBody
public Content saveContent(@ModelAttribute Content content){
System.out.println(content.getImages());
System.out.println(content.getAuthor());
return null;
}
=== Frontend with Angular === home.component.ts:
submitForm() {
const formData = new FormData();
formData.append('author', 'John Smith');
formData.append('images', 'sample.png');
this.http.post<any>('/create', formData).subscribe({
next: (data) => {
console.log('Success');
},
error: (err) => {
console.log(err);
},
})
}
=== Database with MySQL === Database columns