get file extension file upload control in javascript 1

get file extension file upload control in javascript

function getFile(filePath) {
        return filePath.substr(filePath.lastIndexOf('\\') + 1).split('.')[0];
    }

    function getoutput() {
        outputfile.value = getFile(inputfile.value);
        extension.value = inputfile.value.split('.')[1];
    }

Here is what the above code is Doing:
1. It’s getting the file name from the input file path.
2. It’s getting the file extension from the input file path.
3. It’s setting the output file name to the file name from the input file path.
4. It’s setting the output file extension to the file extension from the input file path.

Similar Posts