Methods
Public Class methods
[ show source ]
# File vendor/rails/actionpack/lib/action_controller/request.rb, line 839
839: def self.included(base)
840: base.class_eval do
841: attr_accessor :original_path, :content_type
842: alias_method :local_path, :path
843: end
844: end
Public Instance methods
Take the basename of the upload‘s original filename. This handles the full Windows paths given by Internet Explorer (and perhaps other broken user agents) without affecting those which give the lone filename. The Windows regexp is adapted from Perl‘s File::Basename.
[ show source ]
# File vendor/rails/actionpack/lib/action_controller/request.rb, line 851
851: def original_filename
852: unless defined? @original_filename
853: @original_filename =
854: unless original_path.blank?
855: if original_path =~ /^(?:.*[:\\\/])?(.*)/m
856: $1
857: else
858: File.basename original_path
859: end
860: end
861: end
862: @original_filename
863: end