on Aug 9th, 2008Get the filename from upload form using Javascript

I needed a way to access the filename of a file being uploaded or attached using the input file from a form. So, I created a nice little function to achieve this. Hopefully it comes in handy for someone.

function get_name_from_path(str_filepath)
{
    var obj_re = new RegExp(/([^\/\\]+)$/);
    var str_name = obj_re.exec(str_filepath);

    if (str_name == null)
    {
        return null;
    }
    else
    {
        return str_name[0];
    }
}
Bookmark This

Trackback URI | Comments RSS

Leave a Reply

Are you Human?