Is there a way to check the "Ask where to save each file before downloading" is activated?

Viewed 342

I had a project which is export a csv file and update the download time in admin page and it's worked normally when the browser Ask where to save each file before downloading is disabled. But just for example if the administrator accidentally turn it on then it will create a bug.

The bug : If he/she pressed cancel then my ajax code will still return success call and the download time will be updated despite no files are downloaded Bug Occur when press this button

I don't know if there is a way to check if the Ask where to save each file before downloading is activated or not ?

I'm using Laravel 8 btw , and here is my JS code : enter image description here

1 Answers

This is possible through browser-native FS (https://developer.mozilla.org/en-US/docs/Web/API/FileSystem)

(Works with Chrome and maybe Firefox)

So first you'd do your ajax call to get the CSV file into JavaScript, and then use the BNFS. BNFS generates a user abort exception if the user clicks cancel, so then maybe you'd need to send a message back to the server saying that the download was aborted

Related