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.
# File lib/action_dispatch/http/upload.rb, line 18 18: def original_filename 19: unless defined? @original_filename 20: @original_filename = 21: unless original_path.blank? 22: if original_path =~ /^(?:.*[:\\\/])?(.*)/ 23: $1 24: else 25: File.basename original_path 26: end 27: end 28: end 29: @original_filename 30: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.