Sunday 15 February 2015

html - Get filename from input file in Javascript -


I've found that to parse bootstrap, and to be able to display a top-level file name from a file input field When the user file

  & lt; Input type = "file" id = "exampleFile" & gt;  

JSFiddle:

My question: Has this functionality come up for use in my own Javascript code? Or will I have to parse the file name once again using my technique?

I have tried to retrieve the file name like this:

  $ ('# exampleFile'). Val () // resolves 'C: \ fakepath \ FILENAME' instead of 'FILENAME'  

Good, bootstrap is a framework based on HTML, CSS and javascript. The JavaScript part of this framework uses jQuery and there is no library of itself. You can try to resolve it for a sample by using javascript / jquery with a regex:

  var fullPath = $ ("# exampleFile"). Val (); Var filename = fullPath.replace (/^.*[\\/), '');  

Take a look here:


No comments:

Post a Comment