Hi. I upload a file with this model : class Match < ActiveRecord::Base belongs_to :contest belongs_to :user has_many :comments def replay=(uploaded_file) @uploaded_file = uploaded_file @filename = sanitize_filename(@uploaded_file.original_filename) end def after_create if !File.exists?(File.dirname(self.path_to_file)) FileUtils.mkdir_p(File.dirname(self.path_to_file)) end if @uploaded_file.instance_of?(Tempfile) FileUtils.copy(@uploaded_file.local_path, self.path_to_file) else File.open(self.path_to_file, "wb") { |f| f.write(@uploaded_file.read) } File.chmod(755, self.path_to_file) end write_attribute(:replay, self.path_to_file) self.save end def after_destroy if File.exists?(self.replay) File.delete(self.replay) Dir.rmdir(File.dirname(self.replay)) end end def simple_path "/files/#{self.id}/#{sanitize_filename(self.replay)}" end def path_to_file File.expand_path("#{RAILS_ROOT}/public/files/#{self.id}/ #{@filename}") end private def sanitize_filename(file_name) # get only the filename, not the whole path (from IE) just_filename = File.basename(file_name) # replace all none alphanumeric, underscore or perioids with underscore just_filename.gsub(/[^\w\.\_]/,''_'') end end The problem is that I can''t download the file. The FileUtils.chmod won''t work. I use apache/passenger. the file directory : drwxrwxr-x 4 www-data sobert 4096 oct 16 13:39 files and in file directory : drwxr-xr-x 2 sobert sobert 4096 oct 16 13:43 13 and in 13 directory : -rw------- 1 sobert sobert 275955 oct 16 13:43 Arakan_Citadel_54_mins.SC2Replay How to set the permissions right In order to allow download ? Thanks ! -- 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.