title: How to upload only PDF file and preview in react Js
body: <p>I am doing pdf upload in react js. I want to upload pdf file and just wants to show on the top of the upload button with small div along with remove button, if I click on the remove then it should be removed.</p>
  
  <p>The same I have done it for image successfully. I can upload image and also can preview. But I need some help in doing pdf upload</p>
  
  <p>here is my code, </p>
  
  <pre><code> this.state = {
        file: '',
        imagePreviewUrl: ''
      }
  </code></pre>
  
  <p>getPhoto (e) {
      e.preventDefault();</p>
  
  <pre><code>let reader = new FileReader();
  let file = e.target.files[0];
  
  reader.onloadend = () =&gt; {
    this.setState({
      file: file,
      imagePreviewUrl: reader.result
    });
  }
    reader.readAsDataURL(file);
  }
  
   render() {
    const { imagePreviewUrl, file } = this.state;
    let imagePreview = null;
       if (imagePreviewUrl) {
          imagePreview = (&lt;img src={imagePreviewUrl} /&gt;);
        } else {
          imagePreview = (&lt;div className="previewText"&gt;Please select an Image for Preview&lt;/div&gt;);
        }
  return (
        &lt;React.Fragment&gt;
        &lt;div className={styles.previewBlock}&gt;
          {imagePreview}
          &lt;div className={styles.fileName}&gt;{file.name}&lt;span&gt;
          &lt;i className="fa fa-times" /&gt;&lt;/span&gt;&lt;/div&gt;
        &lt;/div&gt;
    )
   }
  </code></pre>