Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- upload(id) {
- if (id == null)
- return;
- let selectedFile = this.uploader.queue.find(s => s.id == id);
- if (selectedFile) {
- console.log(selectedFile.id);
- const formData = new FormData();
- //formData.append(selectedFile.file.name, selectedFile.file);
- formData.append(selectedFile.id, selectedFile.file);
- const uploadReq = new HttpRequest('POST', `api/upload`, formData, {
- reportProgress: true,
- });
- this.http.request(uploadReq).subscribe(event => {
- if (event.type === HttpEventType.UploadProgress) {
- selectedFile.progress = Math.round(100 * event.loaded / event.total);
- }
- else if (event.type === HttpEventType.Response) {
- selectedFile.message = event.body.toString();
- this.toastr.success('Successfully uploaded file', 'Notification');
- //this.ngxSmartModalService.getModal('myModal').open()
- this.service.getUploads();
- }
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement