title: file upload is not successful ,why?
body: <p>I'm going crazy to upload a file into my ruby 3.2.8 application. I need your help! I tried this code:</p>
  
  <p><a href="https://stackoverflow.com/questions/13286583/why-yaml-file-upload-does-not-work-i-think-permission-problems">Why yaml file upload does not work? I think permission problems</a></p>
  
  <p>but it does not work, does not create the file in "public", but only creates the temporary file. Today I found a new way:</p>
  
  <p><a href="https://stackoverflow.com/questions/5776252/rails-3-upload-files-to-public-directory">Rails 3 - upload files to public directory</a></p>
  
  <p>So, View:</p>
  
  <pre><code>&lt;p style="color: green"&gt;&lt;%= flash[:notice] %&gt;&lt;/p&gt;
  
  &lt;%= form_for :uploadFile, :url =&gt; "/upload/uploadfile", :html =&gt; { :multipart =&gt; true } do |f| %&gt;
    &lt;label for="uploadFile"&gt;Select File:&lt;/label&gt;
    &lt;%= f.file_field :upload %&gt;
    &lt;%= f.submit "Upload", :disable_with =&gt; 'Uploading...' %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>class UploadController &lt; ApplicationController
    def uploadFile
      require 'fileutils'
      tmp = params[:uploadFile][:upload].tempfile
      file = File.join("public", params[:uploadFile][:upload].original_filename)
      FileUtils.cp tmp.path, file
      flash.now[:notice]="File has been uploaded successfully"
    end
  end 
  </code></pre>
  
  <p>but same problem. in "public" there is no file :(</p>
  
  <p>Logs says: </p>
  
  <pre><code>Started POST "/upload/uploadfile" for 127.0.0.1 at 2012-11-12 11:19:04 +0100
  Processing by UploadController#uploadfile as HTML
    Parameters: {"utf8"=&gt;"âœ“", "authenticity_token"=&gt;"WI23X2HeanJpQJoRFc8NUJ078yLYpKgRE3VnJDBeccA=", "uploadFile"=&gt;{"upload"=&gt;#&lt;ActionDispatch::Http::UploadedFile:0x47e4238 @original_filename="newCases.yml", @content_type="application/octet-stream", @headers="Content-Disposition: form-data; name=\"uploadFile[upload]\"; filename=\"newCases.yml\"\r\nContent-Type: application/octet-stream\r\n", @tempfile=#&lt;File:C:/Users/Simo/AppData/Local/Temp/RackMultipart20121112-4716-1geiytj&gt;&gt;}, "commit"=&gt;"Upload"}
    [1m[36mSetting Load (0.0ms)[0m  [1mSELECT "settings".* FROM "settings" WHERE "settings"."id" = ? LIMIT 1[0m  [["id", 1]]
    Rendered upload/uploadfile.html.erb within layouts/upload (0.0ms)
  Completed 200 OK in 16ms (Views: 0.0ms | ActiveRecord: 0.0ms)
  </code></pre>
  
  <p>ahh, the upload file is yaml, change anything?</p>
  
  <p>My gemfile:</p>
  
  <pre><code>source 'https://rubygems.org'
  
  gem 'rails', '3.2.8'
  
  # Bundle edge Rails instead:
  # gem 'rails', :git =&gt; 'git://github.com/rails/rails.git'
  
  gem 'sqlite3'
  
  # Gems used only for assets and not required
  # in production environments by default.
  group :assets do
    gem 'sass-rails',   '~&gt; 3.2.3'
    gem 'coffee-rails', '~&gt; 3.2.1'
  
    # See https://github.com/sstephenson/execjs#readme for more supported runtimes
    # gem 'therubyracer', :platforms =&gt; :ruby
  
    gem 'uglifier', '&gt;= 1.0.3'
  end
  
  gem 'jquery-rails'
  
  gem "comma", "~&gt; 3.0.3"
  gem 'fastercsv', '1.5.4'
  </code></pre>