如何使用 laravel 5 将整个目录从一个文件夹复制到另一个文件夹
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/44665234/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How copy entire directory from one folder two another using laravel 5
提问by Kiyarash
May be it's so easy but I couldn't find any proper answer in google or here!!
可能很简单,但我在谷歌或这里找不到任何正确的答案!!
I did use
我确实用过
\File::copyDirectory('public/' . $token . '/cover/', $folderName . '/cover/');
but there's no different!!
但没有什么不同!!
This is where I found above solution.
Do you know how can I copy entire directory from one folder to another using laravel 5.4?
您知道如何使用 laravel 5.4 将整个目录从一个文件夹复制到另一个文件夹吗?
Thanks in Advance
提前致谢
回答by Bas
More than one year later :)
一年多后:)
Use path helpers functions https://laravel.com/docs/5.6/helpers
使用路径辅助函数https://laravel.com/docs/5.6/helpers
\File::copyDirectory( public_path . 'to/the/app', resource_path('to/the/app'));
回答by tanvir993
We can do it in laravel 5.8 using file facade as followings:
我们可以在 laravel 5.8 中使用文件外观来做到这一点,如下所示:
use Illuminate\Support\Facades\File;
File::copyDirectory(__DIR__.'/form-directory', resource_path('to-directory'));
Hope, it'll be helpful.
希望,它会有所帮助。
回答by brianokinyi
Just do this:
只需这样做:
/* Move test images from public folder to storage folder */
$source = "source/path";
$destination = "public/files";
File::copyDirectory(base_path($source), base_path($destination));
回答by rhysnhall
Try using the mix.copy() method.
尝试使用 mix.copy() 方法。
mix.copy('public/' . $token . '/cover/', $folderName . '/cover/');
mix.copy('public/' . $token . '/cover/', $folderName . '/cover/');
Read more at: https://laravel.com/docs/5.4/mix#copying-files-and-directories
阅读更多信息:https: //laravel.com/docs/5.4/mix#copying-files-and-directories