nodejsHow to extract filename from path
const path = require('path');
let file = path.basename('/home/joe/image.png');ctrl + c| require('path')module to work with file/dir path | .basename(return filename part of a given path | 
| /home/joe/image.pngsample path to extract filename from | |
Usage example
const path = require('path');
let file = path.basename('/home/joe/image.png');
console.log(file)output
image.png
Related
More of Nodejs
- How to POST JSON data
- How to set content type in HTTP server
- How to read stream to Buffer
- How to post url-encoded data
- How to send JSON response from HTTP server
- How to read stream to string
- How to get format date in "yyyy-mm-dd"
- How to get difference between 2 dates in hours
- How to pretty print JSON stringify
- How to import module
See more codes...