当用户单击<input type="file">HTML 中元素中的"浏览"按钮时,我想限制可从本机OS文件选择器中选择的文件类型.我有一种感觉,这是不可能的,但我想知道是否有是一个解决方案.我想完全依赖于HTML和JavaScript; 请不要闪光.
我保存了一个用户定义文件夹的路径shinyDirChoose。现在我想从该用户的文件夹上传文件,但我不知道该怎么做。1)全部在服务器端?2)以fileInput某种方式提供文件路径?
这就是我为应该上传的三个文件构建文件路径的方式。
### ui end, to browse to desired folder
ui = fluidPage(shinyDirButton('directory', 'Folder select', 'Please select a folder'))
### extracting the folder path
server = function(input, output, session) {
volumes <- getVolumes()
shinyDirChoose(input, 'directory', roots=volumes, session=session)
path1 <- reactive({
return(print(parseDirPath(volumes, input$directory)))
})
### constructing the 3 file paths
datpat <- renderText({
req(nchar(path1())>0)
datpat <- paste0(path1(),"/data.csv")
})
vispat <- renderText({
req(nchar(path1())>0)
vispat <- paste0(path1(),"/visit.csv")
})
statpat <- renderText({
req(nchar(path1())>0)
statpat <- paste0(path1(),"/statvisit.csv")
})
Run Code Online (Sandbox Code Playgroud)
所以现在我有了这些路径,但是如何使用它们将相关内容上传到服务器呢?read.csv不幸的是,一个简单的方法并不能解决问题。 …