Forum: Ruby on Rails Upload corrupts images. Any ideas why?

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.
Sergei S. (Guest)
on 2006-04-07 07:53

I have written upload action and it seems to be working in general but
image files consistently get corrupted. They differ in both content and
I have uploaded a small text file without any problems.

Everything is running on my laptop, WEBrick is the server.

          @filename = @params['NewFile'].original_filename
          @filename.gsub!(/[^A-Za-z0-9._]/, '')
 + @filename, "w") { |f|
f.write(@params['NewFile'].read) }
          @error_number = ERROR_NO_PERMISSIONS

Any ideas?

Sergei S.
Red Leaf Software LLC
Sergei S. (Guest)
on 2006-04-07 08:01
The answet was in the wiki already: need to use "wb" mode on Windows.
This topic is locked and can not be replied to.