ofm*_*oon 2 php storage directory-structure file laravel
我有以下文件夹结构:
-storage
-app
-orders
-cat1
-cat2
Run Code Online (Sandbox Code Playgroud)
在 或 文件夹中cat1(cat2取决于用户输入)我想创建另一个文件夹并在其中放置一个 xml 文件。
这就是我尝试在 -folder 中创建目录cat1并将 xml 文件放入其中的方法:
$uuid = Uuid::uuid4();
$id = $uuid->toString();
$path = '/orders/cat1/'.$id;
Storage::makeDirectory($path, 0755, true, true);
Storage::put($id.'test.xml', $xml);
Run Code Online (Sandbox Code Playgroud)
会发生什么:
文件夹($id 作为名称)被创建在正确的位置:
-storage
-app
-orders
-cat1
-123456789
-cat2
Run Code Online (Sandbox Code Playgroud)
但 xml 将存储在此处的另一个文件夹中:
-storage
-app
-123456789 // xml gets stored in another
-test.xml // folder within app-folder
-orders
-cat1
-123456789 // where the xml should be placed
-cat2
Run Code Online (Sandbox Code Playgroud)
我似乎可以找到一种方法将 xml 放入我刚刚创建的目录中._。
Storage::put从文件夹开始app。
使用此代码:
Storage::put($path . '/test.xml', $xml);
Run Code Online (Sandbox Code Playgroud)