Skip to main content
added 7 characters in body
Source Link
Suraj Rao
  • 29.7k
  • 11
  • 96
  • 104

I have followed this link When i check response in my code

 imageUploaded(image:any){
      var headers = new Headers();
      headers.append('Content-Type','multipart/form-data')
      headers.append('Authorization',this.token);
      let formData: FormData = new FormData();
      formData.append('image', image.file);
  this.http.post(this.serverUrl+'photo/upload/user/'+this.userJson.user.public_id,formData, { headers: headers})
        .subscribe(
            response => {
                if(response.json().error_code == 0){
                alert('done')
                    
                }else{
                    this.data = {};
                }
            }
        )
 }

}

When iI verified my API with live the only differance I found in network is the content type For working API-----Content-Type:multipart/form-data; boundary=----WebKitFormBoundaryl4oxlVSt9yblG8VC-----Content-Type:multipart/form-data; boundary=----WebKitFormBoundaryl4oxlVSt9yblG8VC For me -----Content-Type:multipart/form-data-----Content-Type:multipart/form-data

I am missing the boundary with content type.Can anyone please help me.Thanks.

I have followed this link When i check response in my code

 imageUploaded(image:any){
      var headers = new Headers();
      headers.append('Content-Type','multipart/form-data')
      headers.append('Authorization',this.token);
      let formData: FormData = new FormData();
      formData.append('image', image.file);
  this.http.post(this.serverUrl+'photo/upload/user/'+this.userJson.user.public_id,formData, { headers: headers})
        .subscribe(
            response => {
                if(response.json().error_code == 0){
                alert('done')
                    
                }else{
                    this.data = {};
                }
            }
        )

}

When i verified my API with live the only differance I found in network is the content type For working API-----Content-Type:multipart/form-data; boundary=----WebKitFormBoundaryl4oxlVSt9yblG8VC For me -----Content-Type:multipart/form-data

I am missing the boundary with content type.Can anyone please help me.Thanks.

I have followed this link When i check response in my code

 imageUploaded(image:any){
      var headers = new Headers();
      headers.append('Content-Type','multipart/form-data')
      headers.append('Authorization',this.token);
      let formData: FormData = new FormData();
      formData.append('image', image.file);
  this.http.post(this.serverUrl+'photo/upload/user/'+this.userJson.user.public_id,formData, { headers: headers})
        .subscribe(
            response => {
                if(response.json().error_code == 0){
                alert('done')
                    
                }else{
                    this.data = {};
                }
            }
        )
 }

When I verified my API with live the only differance I found in network is the content type For working API-----Content-Type:multipart/form-data; boundary=----WebKitFormBoundaryl4oxlVSt9yblG8VC For me -----Content-Type:multipart/form-data

I am missing the boundary with content type.Can anyone please help me.Thanks.

Source Link
Tracker
  • 435
  • 1
  • 5
  • 9

How to upload image in angular 2

I have followed this link When i check response in my code

 imageUploaded(image:any){
      var headers = new Headers();
      headers.append('Content-Type','multipart/form-data')
      headers.append('Authorization',this.token);
      let formData: FormData = new FormData();
      formData.append('image', image.file);
  this.http.post(this.serverUrl+'photo/upload/user/'+this.userJson.user.public_id,formData, { headers: headers})
        .subscribe(
            response => {
                if(response.json().error_code == 0){
                alert('done')
                    
                }else{
                    this.data = {};
                }
            }
        )

}

When i verified my API with live the only differance I found in network is the content type For working API-----Content-Type:multipart/form-data; boundary=----WebKitFormBoundaryl4oxlVSt9yblG8VC For me -----Content-Type:multipart/form-data

I am missing the boundary with content type.Can anyone please help me.Thanks.