Upload multiple files using Rook

The HTML5 specification allows you to upload multiple files at once via <input type="file", ..., multiple="multiple"> . Is there any way to take advantage of this with the Rook R-package?

Here is my attempt, but it seems that only one of the selected files is displayed:

 library(Rook) app <- function(env) { req <- Rook::Request$new(env) res <- Rook::Response$new() res$write( '<html><body> Select files: <form method="POST" enctype="multipart/form-data"> <input type="file" name="data" multiple="multiple"> <input type="submit" name="Upload"> </form> </body></html>') if (!is.null(req$POST())){ data <- req$POST()[['data']] res$write("<pre>") res$write(paste(capture.output(req$POST(),file=NULL),collapse='\n')) res$write("</pre>") res$write("<pre>") res$write(paste(capture.output(data$filename,file=NULL),collapse='\n')) res$write("</pre>") } res$finish() } s <- Rhttpd$new() s$add(app=RhttpdApp$new(name="app", app=app)) s$start(listen="127.0.0.1", quiet=FALSE) s$browse(1) #s$stop(); s$remove(all=TRUE); rm(s) 
+6
source share
1 answer

The spectrum is not yet fully supported; I just tried Chrome 12.0.742.100, and the browser interface doesn't even allow me to select multiple files.

To upload multiple files, you want to create multiple input elements as follows:

 <input type="file" name="file1">... <input type="file" name="file2">... ... 
+4
source

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


All Articles