#encoding: utf-8
class UpDownLoad < ActiveRecord::Base
def self.upload(params,id)
msg = "{success:false}"
if params[:xlsfile].original_filename.split('.')[1] != 'pdf'
return msg
else
file_path = "#{Rails.root}/public/upload_pdf/#{id}.pdf"
File.open("#{file_path}", "wb") do |f|
f.write(params[:xlsfile].read)
msg = "{success:true}"
end
return msg
end
end
end
下载
send_file(session[:file_path], :type => "text/excel;charset=utf-8; header=present", :disposition => 'attachment')