When I upload a file and request the following params:
params[:product][:images_attributes]["0"][:image]
it returns:
#<ActionDispatch::Http::UploadedFile:0x007fcbe5c8f768 @original_filename="motorized-bicycle-9.jpeg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"product[images_attributes][0][image]\"; filename=\"motorized-bicycle-9.jpeg\"\r\nContent-Type: image/jpeg\r\n", @tempfile=#<File:/var/folders/qf/gjxv0pl142scx9131j0k65_00000gs/T/RackMultipart20140328-969-12np4s4>>
What is the ruby code that I would use to get the filename
?
Try this:
params[:product][:images_attributes]["0"][:image].original_filename
#original_filename
should be the name of the file that the user uploaded, from the documentation on ActionDispatch::Http::UploadedFile.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With