I have a React app with a video player on a page. The player is made with a <video> html tag. There’s a Donwload video button under the player and onClick handler on it. On click this function fires:
const downloadFile = (url: string) => {
const a = document.createElement('a');
a.href = url;
a.click();
};
It works nice on PC, the file downloads without any problems. But when I try to download a file from iPhone then a video opens in fullscreen without ability to download/save it to iPhone. How to fix this?
>Solution :
Hey could you please try this if this helps…
const downloadFile = (url: string, filename: string) => {
const a = document.createElement('a');
a.href = url;
a.setAttribute('download', filename);
a.click();
};
Please let me know if this works..!