Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8339509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T04:54:08+00:00 2026-06-09T04:54:08+00:00

I am attempting to code a very simple way for a user to add

  • 0

I am attempting to code a very simple way for a user to add html files to my Heroku app. These files would be saved in ./log for rendering later. I have tested my code locally (in both development and production), but when I attempt to upload a file on my Heroku hosted repo I get internal server error 500.

controller upload.rb:

class UploadController < ApplicationController
  def index
     render :file => 'upload/uploadfile.haml'
  end

  def uploadFile
    file_param = params[:upload][:datafile]
    post = DataFile.save(file_param)
    render :text => "File has been uploaded successfully"
  end
end

model data_file.rb:

class DataFile < ActiveRecord::Base
  def self.save(upload)
    # Changed Default Destination: [__RAILS_DIR__/log]
    name = "./log/" + upload.original_filename

    # can haz data directory?
    require 'FileUtils'
    FileUtils.mkdir_p(File.dirname(name))


    File.open(name, "wb") { |f| f.write(upload.read) }
  end
end

view uploadfile.haml:

%h1 File Upload
= form_for :upload,:url=>{:action => 'uploadFile'},:html => { :multipart => true } do |f|
  %p
    %label{:for => "upload_file"} Select File
    \:
    \#{f.file_field 'datafile'}
  = f.submit "Upload"

heroku logs:

2012-08-07T14:13:20+00:00 app[web.1]: Started POST "/uploadFile" for 69.29.117.99 at 2012-08-07 14:13:20 +0000
2012-08-07T14:13:20+00:00 app[web.1]: Processing by UploadController#uploadFile as HTML
2012-08-07T14:13:20+00:00 app[web.1]: Parameters: {"utf8"=>"✓", "authenticity_token"=>"1dAXkMulNR0d8S/l6QC8JnpSDtNBaHoyKJezgnheR10=", "upload"=>{"datafile"=>#>}, "commit"=>"Upload"}
2012-08-07T14:13:20+00:00 app[web.1]: Completed 500 Internal Server Error in 3ms
2012-08-07T14:13:20+00:00 app[web.1]: 
2012-08-07T14:13:20+00:00 app[web.1]: LoadError (no such file to load -- FileUtils):
2012-08-07T14:13:20+00:00 app[web.1]: app/models/data_file.rb:7:in save'
2012-08-07T14:13:20+00:00 app[web.1]: app/controllers/upload_controller.rb:8:inuploadFile'
2012-08-07T14:13:20+00:00 app[web.1]: 
2012-08-07T14:13:20+00:00 app[web.1]: 
2012-08-07T14:13:20+00:00 app[web.1]: cache: [POST /uploadFile] invalidate, pass

heroku: http://upload-example.herokuapp.com/

github: https://github.com/halterj1/upload

Please no trying to convince me to use paperclip or carrierwave, that does not answer my question. Any help would be greatly appreciated, thanks in advance guys!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T04:54:09+00:00Added an answer on June 9, 2026 at 4:54 am

    You should read this article on heroku: https://devcenter.heroku.com/articles/read-only-filesystem

    edit:

    As stated in article.

    Your app is compiled into a slug for fast distribution across the dyno manifold. The filesystem for the slug is read-only, which means you cannot dynamically write to the filesystem for semi-permanent storage. The following types of behaviors are not supported:

    • Caching pages in the public directory
    • Saving uploaded assets to local disk (e.g. with attachment_fu or paperclip)
    • Writing full-text indexes with Ferret
    • Writing to a filesystem database like SQLite or GDBM
    • Accessing a git repo for an app like git-wiki

    There are two directories that are writeable: ./tmp and ./log (under your application root). If you wish to drop a file temporarily for the duration of the request, you can write to a filename like #{RAILS_ROOT}/tmp/myfile_#{Process.pid}. There is no guarantee that this file will be there on subsequent requests (although it might be), so this should not be used for any kind of permanent storage.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm attempting to solve what I thought would be a very simple problem. I
I'm attempting to code Box and Whiskers graphs in html. The issue is, I
I'm looking for a simple & semantic way to code jQuery event handlers that
I'm attempting to build a very simple wxPython GUI that monitors and displays external
I am attempting to write a very simple rake task (and merge it into
I'm attempting my first google app engine project – a simple player stats database
I'm attempting to create an iOS 5 app with some very basic FTP functionality
this is killing me but is there any simple way to have objective-c code
I have the following, very simple html page: <html> <head> <script type="text/javascript"> function alertSelection()
I'm attempting to write a simple B+tree implementation (very early stages). I've got a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.