When you upload a file in ruby, from IE, you get the full path when you do temp_file.original_filename or filename. You are supposed to be able to use File.basename(filename) from ruby to strip that out - but it doesn’t really work b/c if you are running in linux and someone from windows uploads a file in I.e. (a highly likely scenario) - the path delimiters for linux don’t jive with the path delimiters for windows, and so - it doesn’t work.

I ended up using Rick Olson’s attachement_fu code instead.

The relevant bit here:
def sanitize_filename(filename)
returning filename.strip do |name|
# NOTE: File.basename doesn't work right with Windows paths on Unix
# get only the filename, not the whole path
name.gsub! /^.*(\\|\/)/, ''

# Finally, replace all non alphanumeric, underscore or periods with underscore
name.gsub! /[^\w\.\-]/, '_'
end
end