too long

I am trying to define a path in php like

 getcwd().'\json_files\'.$file_info['filename'];

but its not working, here $file_info['filename']; is file name.

Using backslashes in a file path only works on Windows computers. Chances are that you are developing in Windows and the server the code is running on is Unix-like (using forward slashes).

The DIRECTORY_SEPARATOR constant is used to define whether the current system uses forward or backward slashes for this, but there is a really nice answer:

Just use forward slashes

If you are on Linux, forward slashes work. If you are on Mac, forward slashes work. Most importantly, if you are on Windows, forward slashes work.

You only need to know what the system's directory separator character is when you are comparing paths provided by the operating system.