Can't read an uploaded file with Ruby's Framework Padrino -
i have form uploading files:
-# coding: utf-8 - content_for(:body_classes, "body3") .content - form_tag url(:images, :create), :method => :post, :multipart => true = file_field_tag :file = submit_tag "upload"
and controller handle it:
fbapp.controllers :images :new render 'images/new' end post :create require 'net/ftp' file = params[:file] ftp = net::ftp.new('xxx.xxx.xxx.xxx') ftp.passive = true ftp.login('user','pass') ftp.storbinary("stor " + "original_filename", stringio.new(file.read), net::ftp::default_blocksize) ftp.quit end end
and every time try upload file "internal server error". , log has this:
nomethoderror - undefined method `read' #<hash:0x00000003697780>:
i'm trying on heroku way. can't figure out what's problem... seems work lot of people me.
you should use:
file = params[:file][:tempfile]
and suggest retrieve filename
name = params[:file][:filename]
Comments
Post a Comment