diff --git a/app/controllers/admin/olympiamanagements_controller.rb b/app/controllers/admin/olympiamanagements_controller.rb index 5e21d18..a60293b 100644 --- a/app/controllers/admin/olympiamanagements_controller.rb +++ b/app/controllers/admin/olympiamanagements_controller.rb @@ -393,7 +393,11 @@ class Admin::OlympiamanagementsController < OrbitAdminController redirect_to :back else tmp_filename_data = @student.olympia_student_images.last.student_file.file.read - send_data(tmp_filename_data, type: 'image/jpg', disposition: 'attachment', filename: "#{@student.StudentName}.jpg") + file = @student.olympia_student_images.last.student_file.file.file.to_s + extname = File.extname(file) rescue ".jpg" + extname = ".jpg" if extname.blank? + mime_type = MIME::Types.type_for(file).first.content_type rescue "image/jpg" + send_data(tmp_filename_data, type: mime_type, disposition: 'attachment', filename: "#{@student.StudentName}#{extname}") end else @student_data_list = OlympiaStudentDataField.where(:sign_up_setting_id=>@sign_up_setting_id) diff --git a/app/views/admin/olympiamanagements/_image_form.html.erb b/app/views/admin/olympiamanagements/_image_form.html.erb index 5ec1217..fa9b1ff 100644 --- a/app/views/admin/olympiamanagements/_image_form.html.erb +++ b/app/views/admin/olympiamanagements/_image_form.html.erb @@ -4,7 +4,21 @@