I have a folder structure as follows:
mydomain.com ->Folder-A ->Folder-B
I have a string from Database that is \'../Folder-B/imag
You could use PHP's dirname function. . That will give you the name of the parent directory of __DIR__, which stores the current directory.
__DIR__