1
<input type="file" onChange={this.handleFileChange} />

private handleFileChange = (e: any) => {
    console.log(e.target.files[0]);
}

With the above React code I have access to the file (could be pdf, text etc.) but I'm interested in knowing if there's a way to preview the file (via a URL) on the client side, ie, before its uploaded to the server.

blankface
  • 5,757
  • 19
  • 67
  • 114
  • Maybe this will help https://stackoverflow.com/questions/750032/reading-file-contents-on-the-client-side-in-javascript-in-various-browsers – A. Meshu Nov 10 '18 at 11:38
  • Not exactly what I was looking for. I'm thinking more along the lines of storing it localStorage or something and then viewing it through a unique URL – blankface Nov 10 '18 at 23:07

0 Answers0