app/controllers/fckeditor_controller.rb
# upload a new file
# currently the FCKeditor docs only allow for 2 errors here
# file renamed and invalid file name
# not sure how to catch invalid file name yet
# I'm thinking there should be a permission denied error as well
upload a new file
currently the FCKeditor docs only allow for 2 errors here
file renamed and invalid file name
not sure how to catch invalid file name yet
I'm thinking there should be a permission denied error as well
upload a new file currently the FCKeditor docs only allow for 2 errors here file renamed and invalid file name not sure how to catch invalid file name yet I ' m thinking there should be a permission denied error as well
def upload_file
    counter = 1
    @file_name = params[:NewFile].original_filename
    ext = File.extname(@file_name)
    path = File.basename(@file_name, ext)
    filetype = params[:Type].downcase.to_sym
    if type_allowed(filetype, ext)
      while File.exist?(File.join(@options[:dir], @file_name))
        @file_name = "#{path}(#{counter})#{ext}"
        @error = 201
        counter += 1
      end
      File.open("#{@options[:dir]}#{@file_name}", 'wb') do |f| 
        f.write(params[:NewFile].read)
      end
    else
      @error = 202
    end
    render :template => 'fckeditor/upload_file'
  end
def upload_file counter = 1 @file_name = params [ :NewFile ] . original_filename ext = File . extname ( @file_name ) path = File . basename ( @file_name , ext ) filetype = params [ :Type ] . downcase . to_sym if type_allowed ( filetype , ext ) while File . exist? ( File . join ( @options [ :dir ] , @file_name ) ) @file_name = "#{path}(#{counter})#{ext}" @error = 201 counter += 1 end File . open ( "#{@options[:dir]}#{@file_name}" , 'wb' ) do | f | f . write ( params [ :NewFile ] . read ) end else @error = 202 end render :template => 'fckeditor/upload_file' end
upload a new file
currently the FCKeditor docs only allow for 2 errors here
file renamed and invalid file name
not sure how to catch invalid file name yet
I'm thinking there should be a permission denied error as well
upload a new file currently the FCKeditor docs only allow for 2 errors here file renamed and invalid file name not sure how to catch invalid file name yet I ' m thinking there should be a permission denied error as well
# break it up into file and extension # we need this to check the types and to build new names if necessary # check to make sure this extension isn't in deny and is in allow # invalid file type