Restrict file upload to some file extensions

后端 未结 4 1711
情书的邮戳
情书的邮戳 2021-02-12 15:36

I am having a problem with uploading files. I want to allow users to upload files that the system allows...

For example, I allow files having an extension of *.j

4条回答
  •  说谎
    说谎 (楼主)
    2021-02-12 16:04

    With HTML5 you can use the :accept for limiting mime-types, like so:

     <%= file_field_tag :csv_file,  :accept => 'text/csv' %>
    

提交回复
热议问题