代码之家  ›  专栏  ›  技术社区  ›  Harat

laravel dd(storage_path('app/public/file_name'))在linus和window中分别给出了不同的结果。

  •  0
  • Harat  · 技术社区  · 7 年前

    在Windows中生成

    drive_name\project_name\storage\app/public/file_name/
    

    结果在Linux

    drive_name\project_name\storage\app\public\file_name\
    

    不同的路径以“/”和“\”斜杠到不同的平台。

    如何处理????

    1 回复  |  直到 7 年前
        1
  •  2
  •   Amarjit Singh    7 年前

    你可以使用 realpath() 函数获取绝对路径。 这将在操作系统中用\替换“/”。

    因此

    只需更换 dd(storage_path('app/public/file_name'))

    具有

    dd(realpath(storage_path('app/public/file_name')))
    
    推荐文章