Html 使用Rook上载多个文件
HTML5规范允许通过Html 使用Rook上载多个文件,html,r,r-rook-package,Html,R,R Rook Package,HTML5规范允许通过一次上传多个文件。有没有一种方法可以在R包中利用这一点 这是我的尝试,但它似乎只显示一个选定的文件: library(Rook) app <- function(env) { req <- Rook::Request$new(env) res <- Rook::Response$new() res$write( '<html><body> Select files: <form me
一次上传多个文件。有没有一种方法可以在R包中利用这一点
这是我的尝试,但它似乎只显示一个选定的文件:
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)
库(Rook)
app尚未完全支持该规范;我刚刚试过Chrome12.0.742.100,浏览器界面甚至不允许一个人选择多个文件
要上载多个文件,您需要创建多个输入元素,如下所示:
。。。
...
...
Hmmm。。。您可能希望将此邮件发送到Rook邮件列表。我知道可以用RApache上传多个文件。谢谢你的回答。我可以用Firefox4.x选择多个文件,但在Rook环境中没有看到它们。
<input type="file" name="file1">...
<input type="file" name="file2">...
...