Get 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.

 

11 thoughts on “Get the filename from upload form using Javascript”

  1. Hi Richard

    This looks like the function I require but maybe you can confirm…

    I’ve produced a website for our local camera club and a few of us are uploading our pictures but the ftp process is a bit tricky for some less computerate users.

    So I thought I’d use the html file upload on a basic form for them.

    Unfortunately when they select a file it only shows the first part of the path and they’re not sure it’s the correct picture. I’d like to show just the filename, (and extension), below the select field so they can be sure about what they are uploading.

    I know I can’t check filesizes for them with javascript but could I check that the name fits our layout? Basically I’m telling everyone to call their pictures p1.jpg, p2.jpg etc so they drop into the gallery in the right place.

    Many Thanks

    ROD

Leave a Reply

Your email address will not be published. Required fields are marked *