Method description:
Parse the characters at the to parameter into an absolute path.
Grammar:
path.resolve([from ...], to)
Since this method belongs to the path module, the path module needs to be introduced before use (var path= require(“path”) )
Receive parameters:
from source path
to A string that will be parsed to an absolute path
Example:
path.resolve('/foo/bar', './baz')
// returns
'/foo/bar/baz'
path.resolve('/foo/bar', '/tmp/file/')
// returns
'/tmp/file'
path.resolve('wwwroot', 'static_files/png/', '../gif/image.gif')
// if currently in /home/myself/node, it returns
'/home/myself/node/wwwroot/static_files/gif/image.gif'
Another way is to use it as a sequence of cd command shells.
path.resolve('foo/bar', '/tmp/file/', '..', 'a/../subfile')
is similar to:
cd foo/bar
cd /tmp/file/
cd ..
cd a/../subfile
pwd
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn