This code import an axcel to a databse sql server via spring boot, So, i want to connect spring boot to sql server management studio, to practice crud operations, however when I try it i get an error: enter image description here So, I have added the dependencies: enter image description here I have added properties: enter image description here … So, i want to connect spring boot to sql server management studio, to practice crud operations, however when I try it i get an error: enter image description here So, I have added the dependencies: enter image description here I have added properties: enter image description here …
Component
import { Component } from '@angular/core';
import { FileUploadService } from './file-upload.service';
@Component({
selector: 'app-file-upload',
templateUrl: './file-upload.component.html',
styleUrls: ['./file-upload.component.css']
})
export class FileUploadComponent {
fileToUpload: File | null = null;
constructor(private fileUploadService: FileUploadService) {}
handleFileInput(files: FileList): void {
this.fileToUpload = files.item(0);
}
upload(): void {
if (this.fileToUpload) {
this.fileUploadService.uploadFile(this.fileToUpload).subscribe(
data => {
console.log('Success', data);
},
error => {
console.error('Error', error);
}
);
}
}
}
Html
<div>
<input type="file" (change)="handleFileInput($event.target.files)" />
<button (click)="upload()">Upload</button>
</div>
This code import an axcel to a databse sql server via spring boot, So, i want to connect spring boot to sql server management studio, to practice crud operations, however when I try it i get an error: enter image description here So, I have added the dependencies: enter image description here I have added properties: enter image description here … So, i want to connect spring boot to sql server management studio, to practice crud operations, however when I try it i get an error: enter image description here So, I have added the dependencies: enter image description here I have added properties: enter image description here …
Service
import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Observable } from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class FileUploadService {
private baseURL = 'https://mon-api.com/upload';
constructor(private http: HttpClient) {}
uploadFile(file: File): Observable<any> {
const formData: FormData = new FormData();
formData.append('file', file, file.name);
return this.http.post(this.baseURL, formData);
}
}
Module
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { HttpClientModule } from '@angular/common/http';
import { AppComponent } from './app.component';
import { FileUploadComponent } from './file-upload/file-upload.component';
import { FileUploadService } from './file-upload/file-upload.service';
@NgModule({
declarations: [
AppComponent,
FileUploadComponent
],
imports: [
BrowserModule,
HttpClientModule
],
providers: [FileUploadService],
bootstrap: [AppComponent]
})
export class AppModule { }
2
Answers
Component.html
Component.ts
ts
public aDeduire: number = 0;
html