开发者

rails3, confused about using params[:filename].tempfile.path vs params[:filename][:tempfile].path

开发者 https://www.devze.com 2023-02-11 00:13 出处:网络
On a Rails 3 app hosted at Heroku, where a multipart file is POSTed to my app, I\'m trying to use some sample code that says :

On a Rails 3 app hosted at Heroku, where a multipart file is POSTed to my app, I'm trying to use some sample code that says :

File.open(params['filename'][:tempfile].path)

however,开发者_StackOverflow社区 my logs show the error NoMethodErr no such method as tempfile.

I also tried

File.open(params[:filename].tempfile.path)

got the same error.

I added require 'tempfile' to my Controller, made no difference.


When a file is posted to your application, the object in the params should already be a Tempfile so calling [:tempfile] or .tempfile should not be necessary. Try something like this:

File.open params[:filename].path
0

精彩评论

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