This might have been asked early, but I am unable to figure it out, please help me and thanks in advance.
Problem:
I have a link to mp4 video (ex: https://www.learningcontainer.com/wp-content/uploads/2020/05/sample-mp4-file.mp4)
I want to download this video from front end.
I have tried the following method:
const videoHref ='https://www.learningcontainer.com/wp-content/uploads/2020/05/sample-mp4-file.mp4';
const a = Object.assign(document.createElement('a'), {
href: videoHref,
style: 'display: none',
download: 'video.mp4'
});
document.body.appendChild(a);
a.click();
a.remove();
But when I execute this code,
the download will start and fails immediately with error
Failed - No file
Please help me resolve this.
let me know if it worked thanks