In my application pdf file is already generated and stored in storage/app/public/
folder, i want to download that file when click on a download button link, Here is how i'm implementing it but it is not downloading that file.
<button @click="onClick()">DownLoad</button>
onClick() {
axios({
url: 'http://localhost:8000/storage/app/public/filename.pdf',
method: 'GET',
responseType: 'blob',
}).then((response) => {
var fileURL = window.URL.createObjectURL(new Blob([response.data]));
var fileLink = document.createElement('a');
fileLink.href = fileURL;
fileLink.setAttribute('download', 'file.pdf');
document.body.appendChild(fileLink);
fileLink.click();
});
},
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3dC0Mkj
via IFTTT
Aucun commentaire:
Enregistrer un commentaire