Skip to content

re: Get file or folder from a parent/sibling path in HTML? VIEW POST


Not an expert on back end but I think this depends on the server.

If you're not using a server you can use ../ to go up a level. E.g. <img src="../originFolder/subpath/image.png">.

If you're using a server that serves the root directory, then you can write the path like /path/to/image. For example if the root directory is "root" and the image is in "root/folder/image.png", the path would be /folder/image.png. Emphasis on the initial /.

If you are able to customise your server routes then you can rewrite requests to serve whatever you want. For example the image could be in "root/folder1/folder2/image.png", but you could make the server return that file when the request is /whatever. So on the front end you would write: <img src="/whatever">

code of conduct - report abuse