Software Alternatives & Reviews

Angular - POST uploaded file

AngularJS Angular.io
  1. AngularJS lets you extend HTML vocabulary for your application. The resulting environment is extraordinarily expressive, readable, and quick to develop.
    Angular I'm using Angular, TypeScript to send a file, along with JSON Data to a server. Below is my code: Import {Component, View, NgFor, FORM\_DIRECTIVES, FormBuilder, ControlGroup} from 'angular2/angular2';import {Http, Response, Headers} from 'http/http';@Component({ selector: 'file-upload' })@View({directives: [FORM\_DIRECTIVES],template: `File Upload Select file: `})export class FileUploadCmp {public file: File;public url: string;headers: Headers;constructor(public http: Http) { console.log('file upload Initialized'); //set the header as multipart this.headers = new Headers(); this.headers.set('Content-Type', 'multipart/form-data'); this.url = 'http://localhost:8080/test';}//onChange file listenerchangeListener($event): void { this.postFile($event.target);}//send post file to server postFile(inputValue: any): void { var formData = new FormData(); formData.append("name", "Name"); formData.append("file", inputValue.files[0]); this.http.post(this.url +, formData , { headers: this.headers });}} How can I transform the formData to String and send it to the server? I remember in AngularJS (v1) you would use transformRequest. Answer link : https://codehunter.cc/a/angular/angular-post-uploaded-file.

    #Javascript UI Libraries #JS Library #Front-End Frameworks 47 social mentions

  2. Angular is a JavaScript web framework for creating single-page web applications. The code is free to use and available as open source. It is further maintained and heavily used by Google and by lots of other developers around the world.
    I'm using Angular, TypeScript to send a file, along with JSON Data to a server.

    #JavaScript Framework #JS Library #Web Development Tools 283 social mentions

Discuss: Angular - POST uploaded file

Log in or Post with