Uncategorized

How to download a file from the server on react?

Good evening young adventurers, we all know the link tag of HTML, and some of us have faced the issue of needing to download a file directly from server ignoring the router component from React or Angular. Well I have the solution for you, we all know the link tag of HTML , well there is a magic prop, that not many of us know called download, this ignored prop gives us the ability to ignore the navigation to the route and just trigger the download behind it, ignoring router component and just launching the download directly from server.

<a href="direction/to/file.pdf" download="nameOfFile.pdf">Download!</a>
Related Posts
Data Science Master
agosto 19, 2016

Leave Your Comment

Your Name*
Your Webpage

Your Comment*