How to download a file by selecting a directory (downloadButton ())

Hi. I'm SHINY beginner.
I want to enable a user to download a csv file using my shiny app in a web browser.
So I searched and found the method below and first I created a simple app for testing.
I uploaded my app to the Ubuntu server and tested the app in a web browser.(Windows 10 PC)

ui <- fluidPage(
    downloadButton("Download", "Download")
)

server <- function(input, output){
 
    output$Download <- downloadHandler(
        filename = function() { 
            paste("dataset-", Sys.Date(), ".csv", sep="")
        },
        content = function(file){
                temp <- setwd(tempdir())
                on.exit(setwd(temp))
                write.csv(mtcars, file)
    
        }
    )
}

This feature works fine in the IDE.
However, when running this test app in a web browser, the csv file was downloaded only to the Download folder. (C: \ Users \ Name \ Downloads)
I would like to know how to download to the directory specified by the user.
If possible, please let me know by example and thank you in advance

Short answer: I think this is not possible, I once read something about this issue saying it is forbidden due to security reasons to write something from the browser directly to your hard-drive.(However this seems to exclude nasty cookies).
However the user can configure its browser so it always asks were to store the files. Also they can open the download folder to open the files.

Longer answer: The working directory of the app working on the server is for sure different from the path where the user want to have its data stored. Assuming it is possible to save the files directly the user should be requested to define the output folder. In other words you need to grab an input where the data should go to and include this then into the export path. As I said it's easier to define this just during the download.

Thank you for your reply. But I do not know how to implement the method you said.
I would really appreciate if you could give me some example code for me.

I'd your app is for local use then this is a solution

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.