开发者

How to access uploaded files in Ruby

开发者 https://www.devze.com 2022-12-27 04:16 出处:网络
I am trying use a Java Uploader in a ROR app (for its ease of uploading entire directories). The selected uploader come开发者_开发问答s with some PHP code that saves the files to the server.I am tryin

I am trying use a Java Uploader in a ROR app (for its ease of uploading entire directories). The selected uploader come开发者_开发问答s with some PHP code that saves the files to the server. I am trying to translate this code to Ruby, but am stumped on this point:

PHP has a very convenient superglobal – $_FILES – that contains a hash of all files uploaded to the current script via the HTTP POST method. It appears Ruby does not have a similar resource. Lacking that, what is the best way to access and save the uploaded files?

I am using the JavaPowUpload uploader ( http://www.element-it.com/OnlineHelpJavaPowUpload/index.html ).


ruby on rails allows you use the application root directory to get at the file stored (wherever you have decided to put it) via #{RAILS_ROOT}.

Check out this tutorial. Not the prettiest method, but it should give you an idea of what needs to be done. Once the file is uploaded, it's just a matter of getting the right path and doing your processing from there.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号