新手问题 怎么获取上传文件的大小 undefined method `length'

suntianxiang · 2014年10月20日 · 最后由 heylonj 回复于 2014年10月20日 · 1432 次阅读

我的 action def updeal file = params["upfile"] detail = "type" + file.content_type.strip if file.length > 1 File.open('a.txt',"wb+") do |f| f.write(file.read) end end render(:text =>detail) end 为啥不能用 length 方法?还有啥方法获得吗

params[:upfile].size or File.size("#{file_name}")

需要 登录 后方可回复, 如果你还没有账号请 注册新账号