Access a file within a folder with spaces in the name in PHP

前端 未结 1 1877
鱼传尺愫
鱼传尺愫 2021-01-18 16:26

I would like to open a file inside a folder in PHP. The problem is that the folder that contains the file may have spaces in the name. The code I use to open the file (and d

相关标签:
1条回答
  • 2021-01-18 16:44

    Backslashes are used to escape spaces on the command line, because spaces on the command line are argument separators. There's no such problem in PHP. If you give any string to fopen, it expects that this one string is one path. It does not break the path into separate arguments at the spaces because that makes no sense in this context.

    Therefore, just don't add any backslashes. The path path/to\ the/file.txt is not the same as the path path/to the/file.txt.

    0 讨论(0)
提交回复
热议问题