title: error in uploading the image from angular to nodejs
body: <p>My <code>Html file</code> is - </p>
  
  <pre><code>&lt;form method="post" [formGroup]="orderForm" enctype="multipart/form-data" (ngSubmit)="OnSubmit(orderForm.value)" &gt;
        &lt;div class="form-group"&gt;
          &lt;label for="image"&gt;Select Branch Image&lt;/label&gt;
          &lt;input type="file" formControlName="branchImg" (change)="onFileChange($event)" class="form-control-file" id="image"&gt;
        &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>and my <code>.ts file</code> is -</p>
  
  <pre><code>public orderForm: FormGroup;
  
  onFileChange(event) {
      const reader = new FileReader();
  
      if (event.target.files &amp;&amp; event.target.files.length) {
        const [file] = event.target.files;
        reader.readAsDataURL(file);
  
        reader.onload = () =&gt; {
          this.orderForm.patchValue({
            branchImg: reader.result
          });               
        };
      }
    }
  
  ngOnInit() {
      this.orderForm = this.formBuilder.group({
        branchImg: [null, Validators.required]
      });
    }
  </code></pre>
  
  <p>and then submit the form.</p>
  
  <p>I am supposed to get the image address and the upload that address in <code>cloudinary</code></p>
  
  <p>But when I am consoling the body in my nodejs app</p>
  
  <p>it gives something like this-</p>
  
  <pre><code>branchImg: 'data:image/jpeg;base64,/9j/4AAQSkZJRgABAgAAAQABAAD/7QCEUGhvdG9zaG9wIDMuMAA4QklNBAQAAAAAAGccAigAYkZCTUQwMTAwMGE4MjBkMDAwMD and so on.
  </code></pre>
  
  <p>I don't think that it is the images address. Can anyone tell me that what is this? and how to get that image's address which I will upload to cloudinary</p>
  
  <p><strong>As the Eric suggest -</strong></p>
  
  <p>my app.js code is </p>
  
  <pre><code>router.post('/branch',(req,res) =&gt;{
      const body = req.body;
        const base64Data = body.branchImg.replace(/^data:image\/png;base64,/, "");
        console.log(base64Data);
        fs.writeFile("out.jpg", base64Data, 'base64', function(err,result) {
          console.log(result);
        });
   });
  </code></pre>
  
  <p>it gives <code>result</code> as <code>undefined</code></p>