当前位置: 首页>>代码示例>>PHP>>正文


PHP Actions::deleteDir方法代码示例

本文整理汇总了PHP中Actions::deleteDir方法的典型用法代码示例。如果您正苦于以下问题:PHP Actions::deleteDir方法的具体用法?PHP Actions::deleteDir怎么用?PHP Actions::deleteDir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Actions的用法示例。


在下文中一共展示了Actions::deleteDir方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: createFileFromChunks

 /**
  * Check if all the parts exist, and 
  * gather all the parts of the file together
  *
  * @param string $location  - the final location
  * @param string $temp_dir  - the temporary directory holding all the parts of the file
  * @param string $fileName  - the original file name
  * @param string $chunkSize - each chunk size (in bytes)
  * @param string $totalSize - original file size (in bytes)
  * @param string $logloc    - relative location for log file
  *
  * @return uploaded file
  */
 public function createFileFromChunks($location, $temp_dir, $fileName, $chunkSize, $totalSize, $logloc)
 {
     global $chunk;
     $upload_dir = str_replace('\\', '', $location);
     $extension = File::getFileExtension($fileName);
     // count all the parts of this file
     $total_files = 0;
     foreach (scandir($temp_dir) as $file) {
         if (stripos($file, $fileName) !== false) {
             $total_files++;
         }
     }
     $finalfile = FileManager::safeExtension($fileName, $extension);
     // check that all the parts are present
     // the size of the last part is between chunkSize and 2*$chunkSize
     if ($total_files * $chunkSize >= $totalSize - $chunkSize + 1) {
         // create the final file
         if (($openfile = fopen($upload_dir . $finalfile, 'w')) !== false) {
             for ($i = 1; $i <= $total_files; $i++) {
                 fwrite($openfile, file_get_contents($temp_dir . '/' . $fileName . '.part' . $i));
             }
             fclose($openfile);
             // rename the temporary directory (to avoid access from other
             // concurrent chunks uploads) and than delete it
             if (rename($temp_dir, $temp_dir . '_UNUSED')) {
                 Actions::deleteDir($temp_dir . '_UNUSED');
             } else {
                 Actions::deleteDir($temp_dir);
             }
             $chunk->setSuccess(" <span><i class=\"fa fa-check-circle\"></i> " . $finalfile . " </span> ", "yep");
             $chunk->setUserUp($totalSize);
             $message = array('user' => GateKeeper::getUserInfo('name'), 'action' => 'ADD', 'type' => 'file', 'item' => $logloc . $finalfile);
             Logger::log($message, "");
             if (SetUp::getConfig("notify_upload")) {
                 Logger::emailNotification($logloc . $finalfile, 'upload');
             }
         } else {
             setError(" <span><i class=\"fa fa-exclamation-triangle\"></i> cannot create the destination file", "nope");
             return false;
         }
     }
 }
开发者ID:anteknik,项目名称:arsip,代码行数:55,代码来源:class.php


注:本文中的Actions::deleteDir方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。