Hi,
After hosting my sample app for file upload on heroku using the FREE
account, it does not work properly. However, everything works fine on
my local machine.  Please help
FOR FILE UPLOAD::
// controller.rb
def uploadFile
   if  params[:upload] == nil
         redirect_to(:action => :home, :notice => "File field must
not
be empty")
    else
            name =  params[:upload].original_filename
                 directory = "keePass/public/data"
                      path = File.join(directory, name)
                File.open(path, "wb") { |f|
f.write(params[:upload].read) }
            redirect_to(:action => :arrive, :notice => "File has been
uploaded successfully")
    end
end
// view.html.erb
<h1>File Upload</h1>
<% form_tag ({:action =>''uploadFile''},
:multipart=>true) do %>
<p><label for="upload_file">Select File</label> :
<input type="file" name="upload" /><br/>
<%= submit_tag "Upload" %>
<% end %>
TWO::: FOR DELETING OF UPLOADED FILE(S)
//controller.rb
def cleanup
  file = params[:file]
       @numFiles = 0
           dir = Dir.entries(''keePass/public/data/'')
                dirN = Array.new
                       dir.each{|x|
                                if File.exist?(x) == false
                                       dirN << x
                                end
                               }
                        if dirN ==[]
                             redirect_to(:action =>:arrive, :notice =>
''There are no files in this folder!'')
                        else
                                dirN.each{|c|
                                     File.delete(File.join(''keePass/
public/data/'',c))
                                             @numFiles +=1
                                          }
                             redirect_to(:action =>:arrive, :notice =>
" #{@numFiles} File(s) deleted!")
                        end
end
// view.html.erb
<%=link_to ''Delete All Files'', :action => :cleanup%>
-- 
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
Heroku does not support file uploads. The filesystem is readonly. You''ll have to host your files somewhere else. S3 is a common choice: http://devcenter.heroku.com/articles/s3 -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
See here: http://devcenter.heroku.com/articles/read-only-filesystem -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Wed, May 4, 2011 at 12:54 PM, ken bob <newkevid-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > After hosting my sample app for file upload on heroku using the FREE > account, it does not work properly. However, everything works fine on > my local machine. Please help > > FOR FILE UPLOAD:: > // controller.rb > def uploadFile > if params[:upload] == nil > redirect_to(:action => :home, :notice => "File field must not > be empty") > else > name = params[:upload].original_filename > directory = "keePass/public/data" > path = File.join(directory, name) > File.open(path, "wb") { |f| > f.write(params[:upload].read) } > redirect_to(:action => :arrive, :notice => "File has been > uploaded successfully") > end > > end > > // view.html.erb > <h1>File Upload</h1> > > <% form_tag ({:action =>''uploadFile''}, :multipart=>true) do %> > <p><label for="upload_file">Select File</label> : > <input type="file" name="upload" /><br/> > <%= submit_tag "Upload" %> > <% end %> > > > > TWO::: FOR DELETING OF UPLOADED FILE(S) > //controller.rb > def cleanup > file = params[:file] > @numFiles = 0 > dir = Dir.entries(''keePass/public/data/'') > dirN = Array.new > dir.each{|x| > if File.exist?(x) == false > dirN << x > end > } > if dirN ==[] > redirect_to(:action =>:arrive, :notice => > ''There are no files in this folder!'') > else > dirN.each{|c| > File.delete(File.join(''keePass/ > public/data/'',c)) > @numFiles +=1 > } > redirect_to(:action =>:arrive, :notice => > " #{@numFiles} File(s) deleted!") > end > end > > // view.html.erb > <%=link_to ''Delete All Files'', :action => :cleanup%> >Maybe you have reasons why not, but if you use the Paperclip gem, it has easy integration with S3.> > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.