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


PHP FileUtils::safeDeleteFile方法代码示例

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


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

示例1: _deleteTempAvatarFiles

 private function _deleteTempAvatarFiles($uid)
 {
     $files = $this->_getTempAvatarFiles($uid);
     $path = UploadUtils::getTempAvatarPath();
     foreach ($files as $fileName) {
         FileUtils::safeDeleteFile($path . '/' . $fileName);
     }
 }
开发者ID:frogoscar,项目名称:mobcent-discuz,代码行数:8,代码来源:SaveAvatarAction.php

示例2: _runAction

 private function _runAction($res, $uid)
 {
     ($imageData = file_get_contents('php://input')) === false && ($imageData = $GLOBALS['HTTP_RAW_POST_DATA']);
     //$imageData = file_get_contents('http://appbyme.com/mobcentACA/resource/images/logo.jpg');
     if (!empty($imageData)) {
         if (($savePath = UploadUtils::getTempAvatarPath()) != '') {
             $fileName = sprintf('%s/avatar_%s.jpg', $savePath, $uid);
             if (($pfile = fopen($fileName, 'wb')) != false) {
                 if (fwrite($pfile, $imageData) !== false) {
                     $image = $this->_uploadAvatarByUcenter($uid, $fileName, $imageData);
                 }
                 fclose($pfile);
                 FileUtils::safeDeleteFile($fileName);
                 if (!empty($image)) {
                     return array_merge($res, array('icon_url' => '', 'pic_path' => $image));
                 }
             }
         }
     }
     return WebUtils::makeErrorInfo_oldVersion($res, WebUtils::t('上传文件失败'));
 }
开发者ID:frogoscar,项目名称:mobcent-discuz,代码行数:21,代码来源:UploadAvatarAction.php

示例3: _doUpload

 private function _doUpload($res, $type)
 {
     $config = WebUtils::getMobcentConfig('misc');
     $path = $config['apnsCertfilePath'];
     $certfileAPNs = $path . '/' . $config['apnsCertfileName'];
     if ($type == 'add_certfile_apns') {
         $password = (string) $_POST['passphrase'];
         if (UploadUtils::makeBasePath($path)) {
             if (!empty($_FILES) && count($_FILES) && is_uploaded_file($_FILES['file']['tmp_name']) && !$_FILES['file']['error']) {
                 FileUtils::saveFile($certfileAPNs, file_get_contents($_FILES['file']['tmp_name']));
                 AppbymeConfig::setAPNsCertfilePassword($password);
             } else {
                 $res = $this->makeErrorInfo($res, WebUtils::t('上传失败'));
             }
         }
     } else {
         if ($type == 'del_certfile_apns') {
             FileUtils::safeDeleteFile($certfileAPNs);
         }
     }
     return $res;
 }
开发者ID:caidongyun,项目名称:CS,代码行数:22,代码来源:ServerUploadAction.php

示例4: getThumbImageEx

 public static function getThumbImageEx($image, $timeout = 15, $getImageInfo = false, $inBackgroud = false, $force = false)
 {
     $res = array('image' => $image, 'ratio' => '1');
     if (empty($image)) {
         return $res;
     }
     $config = self::_getThumbConfig();
     $allowDiscuzThumb = WebUtils::getDzPluginAppbymeAppConfig('image_thumb_allow_discuz');
     if (!$force && !$config['isThumb'] && $allowDiscuzThumb < 0) {
         return $res;
     }
     $thumbImage = $image;
     global $_G;
     $attachFile = '';
     // 是否用discuz生成的缩略图
     if ($allowDiscuzThumb === false || $allowDiscuzThumb > 0) {
         if ($_G['setting']['ftp']['on'] == 0) {
             $attachUrl = self::getAttachUrl();
             $attachUrl = str_replace($attachUrl, '', $image);
             $attachFile = $_G['setting']['attachdir'] . $attachUrl;
             $attachThumbFile = $attachFile . self::DISCUZ_THUMB_SUFFIX;
             if (file_exists($attachThumbFile)) {
                 $res['image'] = $thumbImage . self::DISCUZ_THUMB_SUFFIX;
                 if ($getImageInfo) {
                     $imageInfo = ImageUtils::getImageInfo($attachThumbFile);
                     $res['ratio'] = $imageInfo['ratio'];
                 }
                 return $res;
             }
         }
     }
     if (!$force && !$config['isThumb']) {
         return $res;
     }
     // 获取缩略图文件名
     $savePath = sprintf('%s/%s', MOBCENT_THUMB_PATH, self::_getThumbTempPath($image));
     $tempFileName = self::_getThumbTempFile($image);
     $smallFileName = $savePath . '/mobcentSmallPreview_' . $tempFileName;
     $bigFileName = $savePath . '/mobcentBigPreview_' . $tempFileName;
     if (file_exists($smallFileName) && file_exists($bigFileName)) {
         $res['image'] = self::_getThumbUrlFile($image, $tempFileName);
         if ($getImageInfo) {
             $imageInfo = ImageUtils::getImageInfo($smallFileName);
             $res['ratio'] = $imageInfo['ratio'];
         }
         return $res;
     }
     if ($inBackgroud) {
         CacheUtils::addThumbTaskList($image);
         return $res;
     }
     if (!is_dir($savePath)) {
         mkdir($savePath, 0777, true);
     }
     if (is_writable($savePath)) {
         // $timer = new CountTimer;
         // 先查看是否是本地附件的图片, 如果不是才去网络取图片数据
         $imageData = '';
         if ($attachFile != '' && file_exists($attachFile)) {
             $imageData = file_get_contents($attachFile);
         }
         if ($imageData == '') {
             $imageData = WebUtils::httpRequest($image, $timeout);
             if ($imageData == '') {
                 return $res;
             }
         }
         $thumb = null;
         $zoomRes = true;
         require_once MOBCENT_APP_ROOT . '/components/discuz/source/class/class_image.php';
         if (!file_exists($smallFileName)) {
             if (file_put_contents($smallFileName, $imageData) == false) {
                 return $res;
             }
             $thumb = new Mobcent_Image();
             $zoomRes &= $thumb->makeThumb($smallFileName, '', $config['imageSmallLength']);
         }
         if (!file_exists($bigFileName)) {
             if (file_put_contents($bigFileName, $imageData) == false) {
                 return $res;
             }
             $thumb == null && ($thumb = new Mobcent_Image());
             $zoomRes &= $thumb->makeThumb($bigFileName, '', $config['imageBigLength']);
         }
         if (file_exists($smallFileName) && file_exists($bigFileName) && $zoomRes) {
             $thumbImage = self::_getThumbUrlFile($image, $tempFileName);
             if ($getImageInfo) {
                 $imageInfo = ImageUtils::getImageInfo($smallFileName);
                 $res['ratio'] = $imageInfo['ratio'];
             }
         } else {
             FileUtils::safeDeleteFile($smallFileName);
             FileUtils::safeDeleteFile($bigFileName);
         }
         // var_dump($timer->stop());
     }
     $res['image'] = $thumbImage;
     return $res;
 }
开发者ID:caidongyun,项目名称:CS,代码行数:99,代码来源:ImageUtils.php

示例5: _runAction

 private function _runAction($res, $uid)
 {
     if (empty($_FILES['userAvatar']['tmp_name'])) {
         return WebUtils::makeErrorInfo_oldVersion($res, WebUtils::t('请选择上传的文件'));
     }
     if ($_FILES['userAvatar']['error'] > 0) {
         return WebUtils::makeErrorInfo_oldVersion($res, WebUtils::t('上传文件失败'));
     }
     if ($_FILES['userAvatar']['size'] > 2000000) {
         return WebUtils::makeErrorInfo_oldVersion($res, WebUtils::t('上传文件太大'));
     }
     $savePath = UploadUtils::getTempAvatarPath();
     $fileName = sprintf('%s/avatar_%s.jpg', $savePath, $uid);
     if (move_uploaded_file($_FILES['userAvatar']['tmp_name'], $fileName)) {
         $imageData = file_get_contents($fileName);
         $image = $this->_uploadAvatarByUcenter($uid, $fileName, $imageData);
         FileUtils::safeDeleteFile($fileName);
         if (!empty($image)) {
             return array_merge($res, array('icon_url' => '', 'pic_path' => $image));
         }
         // WebUtils::httpRequestAppAPI('user/saveavatar', array('avatar' => $image, 'hacker_uid' => 1));
         // die();
     }
     return WebUtils::makeErrorInfo_oldVersion($res, WebUtils::t('上传文件失败'));
 }
开发者ID:frogoscar,项目名称:mobcent-discuz,代码行数:25,代码来源:UploadAvatarExAction.php


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