Commit ecbe5f33 authored by Ayush's avatar Ayush

Resolveconflicts

parents d46c684c b931fd13
...@@ -9,7 +9,8 @@ import {HttpClient} from '@angular/common/http'; ...@@ -9,7 +9,8 @@ import {HttpClient} from '@angular/common/http';
}) })
export class FileService { export class FileService {
baseApiUrl = 'http://localhost/sfcode/backend/filesave.php'; saveUrl = 'http://localhost/sfcode/backend/filesave.php';
uploadUrl = 'http://localhost/sfcode/backend/fileupload.php';
constructor(private http: HttpClient) { constructor(private http: HttpClient) {
} }
...@@ -34,7 +35,13 @@ export class FileService { ...@@ -34,7 +35,13 @@ export class FileService {
} }
upload(file): Observable<any> { upload(file): Observable<any> {
return this.http.post(this.baseApiUrl, file); return this.http.post(this.saveUrl, file);
}
upload2(file): Observable<any> {
const formData = new FormData();
formData.append("file", file, file.name);
return this.http.post(this.uploadUrl, formData)
} }
} }
...@@ -40,7 +40,7 @@ export class FileComponent implements OnInit { ...@@ -40,7 +40,7 @@ export class FileComponent implements OnInit {
this.loading = true; this.loading = true;
console.log(this.fileToUpload); console.log(this.fileToUpload);
this.fileService.upload(this.fileToUpload).subscribe( this.fileService.upload2(this.fileToUpload).subscribe(
(event: any) => { (event: any) => {
if (typeof (event) === 'object') { if (typeof (event) === 'object') {
this.fileToUpload = null; this.fileToUpload = null;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment