Request download location instead of direct download

I create a CSV element in JavaScript and then simulate a click to load the corresponding file.

But instead of direct download, I want it to open a download prompt to select the location of the downloaded file.

var csvString = Papa.unparse(result,{ quotes: false, delimiter: ",", newline: "\r\n" }); var a = document.createElement('a'); a.href = 'data:attachment/csv,' + escape(csvString); a.download = "download.csv"; a.click(); 

How can I do that?

+5
source share
1 answer

This is a browser specific setting.

  • In Chrome: go to Settings > Downloads > and then check the Ask where to save each file before downloading box Ask where to save each file before downloading
  • In Firefox: go to Tools > Options , open the General tab and select the Always ask me where to save files radio button
  • In Internet Explorer 8: When the download dialog opens, click the Save button and select a location.
+7
source

Source: https://habr.com/ru/post/1209344/


All Articles