简体   繁体   中英

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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM