title: Angular 7 correctly upload doc/docx file
body: <p>I'm having troubles uploading doc and docx files, because I can't get the right type of file when converting it to base64. This is my input:</p>
  <pre><code>  &lt;input
      accept=&quot;.pdf,.txt,.doc,.docx&quot;
      type=&quot;file&quot;
      (change)=&quot;onNativeInputFileSelect($event)&quot;
      #inputFile
      hidden
    /&gt;
  </code></pre>
  <p>In my method I do this:</p>
  <pre><code>  onNativeInputFileSelect(event) {
      if (event.target.value) {
        const file: File = event.target.files[0];
        this.changeFile(file).then((base64: string): any =&gt; {
          this.attachment.content= base64;
          this.uploadFile(this.attachment);
        });
      }
    }
  </code></pre>
  <p>then in &quot;uploadFile&quot; I send the file to server as base 64 string.<br />
  The <code>changeFile</code> methods is this:</p>
  <pre><code>  changeFile(file) {
      return new Promise((resolve, reject) =&gt; {
        const reader = new FileReader();
        reader.readAsDataURL(file);
        reader.onload = () =&gt; resolve(reader.result);
        reader.onerror = (error) =&gt; reject(error);
      });
    }
  </code></pre>
  <p>This works fine for pdf or txt files, but when I upload .doc or .docx files I get this base64 string:</p>
  <pre><code>data:application/octet-stream;base64,0M8R4KGxGuEAA[...]
  </code></pre>
  <p>while for pdf I correctly have:</p>
  <pre><code>data:application/pdf;base64,JVBERi0xLjQKJeLjz9MKMS
  </code></pre>
  <p>This means that when I try to download the file I don't get the correct type, because I have application/octet-stream, and so I can't put the right extension to the file.<br />
  I've tried by passing to the <code>accept</code> property of input component this:</p>
  <pre><code>application/msword,application/pdf,text/plain,application/vnd.openxmlformats-officedocument.wordprocessingml.document
  </code></pre>
  <p>But nothing changed and the Window's file chooser suggested me only .pdf and .txt files</p>
  <p><strong>EDIT</strong></p>
  <p><a href="https://stackblitz.com/edit/angular7-playground-jbrecy?file=src/app/app.component.html" rel="nofollow noreferrer">This is a working stackblitz</a></p>