Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript - get the filename and extension from input type=file

//Use lastIndexOf to get the last  as an index and use substr to get the remaining string starting from the last index of 

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

    function getoutput() {
        outputfile.value = getFile(inputfile.value);
        extension.value = inputfile.value.split('.')[1];
    }
<input id='inputfile' type='file' name='inputfile' onChange='getoutput()'><br>
    Output Filename <input id='outputfile' type='text' name='outputfile'><br>
    Extension <input id='extension' type='text' name='extension'>
Comment

PREVIOUS NEXT
Code Example
Javascript :: set date to input date js 
Javascript :: react useeffect 
Javascript :: regex to match string not in between quotes 
Javascript :: array to string javascript without commas 
Javascript :: javascript style onclick 
Javascript :: remove property from javascript object 
Javascript :: jquery get meta value 
Javascript :: Find smallest Number from array in javascript 
Javascript :: semantic ui dropdown value 
Javascript :: how to reload the window by click on button in javascript 
Javascript :: killall node windows 
Javascript :: javascript remove final newline from string 
Javascript :: javascript alphabet array 
Javascript :: find last element in array javascript 
Javascript :: scroll down div from component angular 
Javascript :: open modal js 
Javascript :: loop array in javascript 
Javascript :: javascript minimum number in array 
Javascript :: reduce parameters 
Javascript :: how to disable onclick event in javascript 
Javascript :: sort object by key value js 
Javascript :: format money javascript 
Javascript :: react native text capitalize 
Javascript :: jquery window offset top 
Javascript :: To fix, cancel all subscriptions and asynchronous tasks in a useEffect cleanup function. 
Javascript :: call javascript function use array 
Javascript :: predicate function javascript 
Javascript :: mongodb add new field 
Javascript :: momentjs range 
Javascript :: MVC view pass model to javascript function 
ADD CONTENT
Topic
Content
Source link
Name
3+6 =