title: How to upload files to the server in rails?
body: <p>i am willing to upload the file to the server without using any gem. Following is what i have tried:</p>
  
  <p>the following is the function that i have created in modal:</p>
  
  <pre><code>def self.file_upload(uploaded_file)
      puts uploaded_file
      file = Tempfile.new(uploaded_file, 'http://52.41.99.60/GEMWebservices/Image')
  
      returning File.open(file.path, 'w') do |f|
        f.write file.read
        f.close
      end
    end
  </code></pre>
  
  <p>I have used the above function in create acrion as follows:</p>
  
  <pre><code>@file_upload = User.file_upload(params[:uploaded_file])
  </code></pre>
  
  <p>But i get the following error:</p>
  
  <pre><code>unexpected prefix: #&lt;ActionDispatch::Http::UploadedFile:0x007fa0909fbe00 @tempfile=#&lt;Tempfile:/var/folders/tt/d903z3v94sbgr8yymqxn_m0m0000gn/T/RackMultipart20160829-27648-gzgzt8.jpeg&gt;, @original_filename="kaka.jpeg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"uploaded_file\"; filename=\"kaka.jpeg\"\r\nContent-Type: image/jpeg\r\n"&gt;
  </code></pre>
  
  <p>Can any one help me out? Thank you in advance.</p>