Upload corrupts images. Any ideas why?

Hi,

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
size.
I have uploaded a small text file without any problems.

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

Code:


    begin
      @filename = @params['NewFile'].original_filename
      @filename.gsub!(/[^A-Za-z0-9._]/, '')
      File.open(@server_path + @filename, "w") { |f| 

f.write(@params[‘NewFile’].read) }
rescue
@error_number = ERROR_NO_PERMISSIONS
end


Any ideas?

Sergei S.
Red Leaf Software LLC
http://www.redleafsoft.com

The answet was in the wiki already: need to use “wb” mode on Windows.

http://wiki.rubyonrails.com/rails/pages/HowtoUploadFiles