Topic: Uploading pdf

i am trying to upload the pdf. i can select the file but unable to upload
here is my model

  class DataFile < ActiveRecord::Base
    def self.Save(upload)
      name = upload['datafile'].original_filename
      directory = "public/data"
      # create the file path
      path = File.join(directory, name)
      # write the file
      File.open(path, 'w') do |f|
        f.write(upload['datafile'].read)
      end
    end
  end


here is my controller

class UploadController < ApplicationController
  def index
    render :file => 'app\views\upload\uploadfile.html.erb'
  end
  def uploadFile
    post = DataFile.Save(upload)
    render :text => "File has been uploaded successfully"
  end
end

Last edited by kiran kumar cy (2012-09-12 06:28:30)

Re: Uploading pdf

I can select a file but when l click on upload button it says no file has chosen