php how to go one level up on dirname(__FILE__)

后端 未结 9 2059
暗喜
暗喜 2020-11-30 21:52

I have a folder structure as follows:

mydomain.com
  ->Folder-A
  ->Folder-B

I have a string from Database that is \'../Folder-B/imag

9条回答
  •  清歌不尽
    2020-11-30 22:17

    If you happen to have php 7.0+ you could use levels.

    dirname( __FILE__, 2 ) with the second parameter you can define the amount of levels you want to go back.

    http://php.net/manual/en/function.dirname.php

提交回复
热议问题