【问题标题】:CakePHP copy file to new directoryCakePHP 将文件复制到新目录
【发布时间】:2012-03-18 03:51:16
【问题描述】:

根据File api,cakephp 文档有点差,我想用它将一个文件复制到另一个目录,如果该目录不存在则创建它。

谢谢!

【问题讨论】:

    标签: file cakephp copy cakephp-1.3


    【解决方案1】:

    你可以这样做:

    $file = new File('your_file.ext');
    
    if ($file->exists()) {
        $dir = new Folder('folder_inside_webroot', true);
        $file->copy($dir->path . DS . $file->name);
    }
    

    关于这些类的 API:

    希望对你有帮助。

    【讨论】:

      猜你喜欢
      • 2014-11-14
      • 2021-11-27
      • 1970-01-01
      • 2022-01-21
      • 2014-04-30
      • 1970-01-01
      • 2019-11-01
      • 2018-10-27
      • 2014-09-22
      相关资源
      最近更新 更多