Commit b931fd13 authored by Adarsh's avatar Adarsh

minor

parent 35ffb92d
...@@ -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)
} }
} }
...@@ -16,37 +16,6 @@ ...@@ -16,37 +16,6 @@
</div> </div>
<!--<div id="myModal" class="modal" [class.open]="uploadPopupActive">-->
<!-- &lt;!&ndash; Modal content &ndash;&gt;-->
<!-- <div class="modal-content">-->
<!-- <span (click)="onClick2()" class="close">&times;</span>-->
<!-- <div class="text-center">-->
<!-- <input class="form-control" type="file"-->
<!-- (change)="onChange($event)">-->
<!-- <button (click)="onUpload()"-->
<!-- class="btn btn-success">-->
<!-- Upload-->
<!-- </button>-->
<!-- </div>-->
<!-- &lt;!&ndash; Shareable short link of uoloaded file &ndash;&gt;-->
<!-- <div class="container text-center jumbotron"-->
<!-- *ngIf="shortLink">-->
<!-- <h2> Visit Here</h2>-->
<!-- <a href="{{shortLink}}">{{shortLink}}</a>-->
<!-- </div>-->
<!-- &lt;!&ndash;Flag variable is used here&ndash;&gt;-->
<!-- <div class="container" *ngIf="loading">-->
<!-- <h3>Loading ...</h3>-->
<!-- </div>-->
<!-- </div>-->
<!--</div>-->
<div [class.open]="uploadPopupActive" id="file-upload-cover"></div> <div [class.open]="uploadPopupActive" id="file-upload-cover"></div>
......
...@@ -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