Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

upload files with angular

fileChange(element) {
  this.uploadedFiles = element.target.files;
}

upload() {
  let formData = new FormData();
  for (var i = 0; i < this.uploadedFiles.length; i++) {
    formData.append("uploads[]", this.uploadedFiles[i], this.uploadedFiles[i].name);
  }
  this.http.post('/api/upload', formData)
    .subscribe((response) => {
    console.log('response received is ', response);
  })
}
Comment

upload file angular

<input type="file" class="file-upload" (change)="functionName($event)">
Comment

file upload in angular 10 post

onFileSelected(event) {
    if(event.target.files.length > 0) 
     {
       this.myForm.patchValue({
          fileName: event.target.files[0],
       })
     }
  }

submit(){
    const formData = new FormData();
    formData.append('file', this.myForm.get('fileName').value);
   
    this.http.post('http://localhost:3000/upload', formData)
      .subscribe(res => {
        console.log(res);
        alert('Uploaded Successfully.');
      })
  }
Comment

file upload in angular 10

onFileChange(event) {
    const reader = new FileReader();

    if (event.target.files && event.target.files.length) {
      const [file] = event.target.files;
      reader.readAsDataURL(file);
      reader.onload = () => {
        this.data.parentForm.patchValue({
          tso: reader.result
        });

        // need to run CD since file load runs outside of zone
        this.cd.markForCheck();
      };
    }
  }
Comment

angular file upload

upload() {
    let formData = new FormData();
    for (var i = 0; i < this.uploadedFiles.length; i++) {
        formData.append("uploads[]", this.uploadedFiles[i], this.uploadedFiles[i].name);
    }
    this.http.post('/api/upload', formData)
    .subscribe((response) => {
         console.log('response received is ', response);
    })
}
Comment

PREVIOUS NEXT
Code Example
Typescript :: angular rxjs 
Typescript :: javascript block comment 
Typescript :: push array elements if not exists mongoose 
Typescript :: Lists - Learn C# 
Typescript :: accessing formcontrol from fromgroup 
Typescript :: remove elements from array that has same value from other array 
Typescript :: angular initail valeur in fromgroup 
Typescript :: adoni migrate 
Typescript :: whats ruby used for 
Typescript :: mongoose model enum 
Typescript :: The following TestContainer was not found 
Typescript :: typescript use object keys as index 
Typescript :: coldfusion arrayLast 
Typescript :: mat card api 
Typescript :: how to add alias to my hosts in ansible hosts 
Typescript :: format time to am pm 
Typescript :: mailbox exists c# 
Typescript :: golang check array index exists in slice 
Typescript :: python application insights azure 
Typescript :: elements without corner css 
Typescript :: What kind of projects is suitable for the Agile methodology 
Typescript :: ts compile command 
Typescript :: ts pipe function 
Typescript :: type in typescript 
Typescript :: not working npx react-native init MyApp --template react-native-template-typescript 
Typescript :: algorithm that prints if one of the numbers is multiple of the other 
Typescript :: typescript public function 
Typescript :: ts loop through days in dates 
Typescript :: What do HTTP requests and responses look like? 
Typescript :: typescript checkbox object is possibly null 
ADD CONTENT
Topic
Content
Source link
Name
2+7 =