Forum: Ruby on Rails Internet Explorer - Sanitize Uploaded Filenames

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
2562952eccf6bbd7c1a412768ab68f3b?d=identicon&s=25 KindaBlue (Guest)
on 2007-01-18 19:35
(Received via mailing list)
Hi all,

Somewhat of a noob here.  I have a table that has 5 file fields, and
they are named file, file2, file3, file4, file 5.  All of them will be
.doc files.

In firefox, I can upload these files just fine, and they will show up
as Document.doc.  In IE, it prepends the entire path.

C:\My Documents\User\Desktop\Document.doc

Which makes the file unreadable, and un-downloadable.  I know that the
sanitize method is supposed to fix this, but I can't figure out how to
make it work.  Here is what I've written in my model:

def self.sanitize_filename(filename)
  filename = File.basename(filename.gsub("\\", "/"))

Doesn't work.  What do I need to do?  This is bugging me so much.
2562952eccf6bbd7c1a412768ab68f3b?d=identicon&s=25 KindaBlue (Guest)
on 2007-01-19 16:30
(Received via mailing list)
Do I need something in my controller?  View maybe?  Do I need to call
before_save :sanitize_filename?  I've tried that and it gives me a
"wrong arguments" error.
This topic is locked and can not be replied to.