I’m very new in ruby on rails. I’m stuck with a problem. I want to make a file upload functionality through which I can upload any kind of file (text,image etc.). My controller
The reason for the issue is encoding problems. It seems that you are reading the file in ASCII-8BIT mode and writing it in UTF-8 which means a conversion needs to take place. And conversion from ASCII-8BIT to UTF-8 isn't straight forward. Alternatively, you can specify binary mode for both reading and writing the files.
upload_file = File.new(, "rb").read
and
File.open(, "wb") {|f| f.write(upload_file) }