使用rails获取本地html文件的内容
我需要的是将本地 html 文件传递到我的表单,获取该文件的内容,然后解析它。 我看到了这个
= form_tag :parser, :html => {:multipart => true} do
= file_field_tag :html_file
= submit_tag
并且在控制器中这个
def parser
@file = params[:html_file]
end
似乎表单没有获取文件,只是获取带有文件名的字符串。如何修复它?
what i need is passing local html file to my form, get content of this file and later parse it.
I have this in view
= form_tag :parser, :html => {:multipart => true} do
= file_field_tag :html_file
= submit_tag
And this in controller
def parser
@file = params[:html_file]
end
It seems like form dont get file, just get the string with name of file. How to fix it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我写这个是为了处理 Rails 2.3.x 应用程序中的上传。我不记得为什么我必须将其拆分为 if/elsif/else/end 语句,但我一定在将其合并为一个 if 语句时犯了一个错误。
I wrote this to handle uploads in a Rails 2.3.x app. I cannot remember why I had to split this into an if/elsif/else/end statement, but I must have had an error consolidating it to one if statement.