1 year ago

#295428

test-img

Paul

React js download file problem with firefox mobile

I have the following code which allows me to create a .srt file to be able to download it later.

It seems to work fine, but when I use Firefox on android device, the file does download but the file format is not correct, it should be .srt instead it is .txt.

It seems to only happen with Firefox on android, on pc it seems to give no problems.

Where am I doing wrong?

const element = document.createElement("a");
const file = new Blob([value], { type: "text/plain" });
element.href = URL.createObjectURL(file);
element.download = name + num + ".srt";
document.body.appendChild(element); // Required for this to work in FireFox
element.click();

javascript

file

firefox

download

srt

0 Answers

Your Answer

Accepted video resources