Monday, May 31, 2010

How to get file extension in ruby and jquery

To get the file extension excluding the "." then do the following
@file_extension = file_name.split('.').pop()

To get the file extension along with "." then do the following
@file_extension = file_name.scan(/\.\w+$/)

Using Jquery
var ext = $('#file_field_id').val().split('.').pop().toLowerCase();

No comments:

Post a Comment