I am trying to upload an Image.
The image file gets created but the size of the file is 0 bytes.
Here is the code in controller
name = params[:comparison][:image1].original_filename
name_content_type = params[:comparison][:image1].content_type
directory = "public/images"
path = File.join(directory, name)
file = File.open(path, "wb") { |f|
content = params[:comparison][:image1].read
f.write(content)
}
# also tried the below but doesn't work
# file = File.new(path, "wb") { |f| f.write(params[:comparison][:image1].read) }
# RAILS_DEFAULT_LOGGER.info(file) is showing 0
Can anyone point me to working demo with code? I know this is such a simple stuff! not sure why its not working...!!!!