class DataFile < ActiveRecord::Base
def self.save(data, name, directory)
path = File.join(directory, name)
File.open(path, 'wb') do |file|
file.puts data.read
end
#File.open(path, "wb") { |f| f.write(params[:filedata].read) }
end
end
class UploadController < ApplicationController
def index
data = params[:filedata]
name = params[:Filename]
directory = "public/data"
@data_file = DataFile.save(data, name, directory)
render :nothing => true
end
end
|