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


PHP FileSystem::copy_file方法代码示例

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


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

示例1: __construct

 /**
  * Constructor
  */
 public function __construct()
 {
     $cx = \Cx\Core\Core\Controller\Cx::instanciate();
     $folderPath = $cx->getWebsiteTempPath() . '/Update';
     if (!file_exists($folderPath)) {
         \Cx\Lib\FileSystem\FileSystem::make_folder($folderPath);
     }
     if (!file_exists($folderPath . '/' . self::PENDING_DB_UPDATES_YML)) {
         \Cx\Lib\FileSystem\FileSystem::copy_file($cx->getCodeBaseCoreModulePath() . '/Update/Data/' . self::PENDING_DB_UPDATES_YML, $folderPath . '/' . self::PENDING_DB_UPDATES_YML);
     }
     parent::__construct($folderPath . '/' . self::PENDING_DB_UPDATES_YML);
 }
开发者ID:nahakiole,项目名称:cloudrexx,代码行数:15,代码来源:DeltaRepository.class.php

示例2: uploadMedia

 /**
  * Copy the Upload the image to the path
  * Note: validation should be done before calling this function
  *
  * @param string $filePath Temp path of the uploaded media
  *
  * @return boolean|string relative path of the uploaded file, false otherwise
  */
 function uploadMedia($filePath)
 {
     if ($filePath == '' || !\FWValidator::is_file_ending_harmless($filePath)) {
         return false;
     }
     $fileName = basename($filePath);
     //get extension
     $arrFileInfo = pathinfo($fileName);
     $fileExtension = !empty($arrFileInfo['extension']) ? '.' . $arrFileInfo['extension'] : '';
     $fileBasename = $arrFileInfo['filename'];
     $randomSum = rand(10, 99);
     //encode filename
     if ($this->arrSettings['settingsEncryptFilenames'] == 1) {
         $fileName = md5($randomSum . $fileBasename) . $fileExtension;
     }
     //check filename
     if (file_exists($this->imagePath . 'uploads/' . $fileName)) {
         $fileName = $fileBasename . '_' . time() . $fileExtension;
     }
     //upload file
     if (\Cx\Lib\FileSystem\FileSystem::copy_file($filePath, $this->imagePath . 'uploads/' . $fileName) !== false) {
         $objFile = new \File();
         $objFile->setChmod($this->imagePath, $this->imageWebPath, 'uploads/' . $fileName);
         return $this->imageWebPath . 'uploads/' . $fileName;
     } else {
         return false;
     }
 }
开发者ID:Cloudrexx,项目名称:cloudrexx,代码行数:36,代码来源:MediaDirectoryInputfieldFile.class.php

示例3: uploadMedia

 /**
  * Copy the Upload the image to the path
  * Note: validation should be done before calling this function
  * 
  * @param string $imagePath Temp path of the uploaded media
  * 
  * @return boolean|string relative path of the uploaded file, false otherwise
  */
 function uploadMedia($imagePath)
 {
     if ($imagePath == '' || !\FWValidator::is_file_ending_harmless($imagePath)) {
         return false;
     }
     // get extension
     $imageName = basename($imagePath);
     $arrImageInfo = pathinfo($imageName);
     $imageExtension = !empty($arrImageInfo['extension']) ? '.' . $arrImageInfo['extension'] : '';
     $imageBasename = $arrImageInfo['filename'];
     $randomSum = rand(10, 99);
     // encode filename
     if ($this->arrSettings['settingsEncryptFilenames'] == 1) {
         $imageName = md5($randomSum . $imageBasename) . $imageExtension;
     }
     // check filename
     if (file_exists($this->imagePath . 'images/' . $imageName)) {
         $imageName = $imageBasename . '_' . time() . $imageExtension;
     }
     // upload file
     if (\Cx\Lib\FileSystem\FileSystem::copy_file($imagePath, $this->imagePath . 'images/' . $imageName) === false) {
         return false;
     }
     $imageDimension = getimagesize($this->imagePath . 'images/' . $imageName);
     $intNewWidth = $imageDimension[0];
     $intNewHeight = $imageDimension[1];
     $imageFormat = $imageDimension[0] > $imageDimension[1] ? 1 : 0;
     $setNewSize = 0;
     if ($imageDimension[0] > 640 && $imageFormat == 1) {
         $doubleFactorDimension = 640 / $imageDimension[0];
         $intNewWidth = 640;
         $intNewHeight = round($doubleFactorDimension * $imageDimension[1], 0);
         $setNewSize = 1;
     } elseif ($imageDimension[1] > 480) {
         $doubleFactorDimension = 480 / $imageDimension[1];
         $intNewHeight = 480;
         $intNewWidth = round($doubleFactorDimension * $imageDimension[0], 0);
         $setNewSize = 1;
     }
     if ($setNewSize == 1) {
         $objImage = new \ImageManager();
         $objImage->loadImage($this->imagePath . 'images/' . $imageName);
         $objImage->resizeImage($intNewWidth, $intNewHeight, 100);
         $objImage->saveNewImage($this->imagePath . 'images/' . $imageName, true);
     }
     $objFile = new \File();
     $objFile->setChmod($this->imagePath, $this->imageWebPath, 'images/' . $imageName);
     // create thumbnail
     $this->checkThumbnail($this->imageWebPath . 'images/' . $imageName);
     return $this->imageWebPath . 'images/' . $imageName;
 }
开发者ID:Niggu,项目名称:cloudrexx,代码行数:59,代码来源:MediaDirectoryInputfieldImage.class.php

示例4: storeFromPost

 /**
  * Update and store all settings found in the $_POST array
  *
  * Note that you *MUST* call {@see init()} beforehand, or your settings
  * will be unknown and thus not be stored.
  * Sets up an error message on failure.
  * @return  boolean                 True on success, null on noop,
  *                                  or false on failure
  */
 static function storeFromPost()
 {
     global $_CORELANG;
     //echo("self::storeFromPost(): POST:<br />".nl2br(htmlentities(var_export($_POST, true)))."<hr />");
     //echo("self::storeFromPost(): FILES:<br />".nl2br(htmlentities(var_export($_FILES, true)))."<hr />");
     // There may be several tabs for different groups being edited, so
     // load the full set of settings for the module.
     // Note that this is why setting names should be unique.
     // TODO: You *MUST* call this yourself *before* in order to
     // properly initialize the section!
     // self::init();
     $engine = self::getSectionEngine();
     if ($engine == null) {
         return false;
     }
     $arrSettings = $engine->getArraySetting();
     $submittedGroup = !empty($_POST['settingGroup']) ? $_POST['settingGroup'] : null;
     unset($_POST['bsubmit']);
     $result = true;
     // Compare POST with current settings and only store what was changed.
     foreach (array_keys($arrSettings) as $name) {
         if (isset($_POST[$name])) {
             $value = contrexx_input2raw($_POST[$name]);
             //if (preg_match('/^'.preg_quote(CSRF::key(), '/').'$/', $name))
             //continue;
             switch ($arrSettings[$name]['type']) {
                 case self::TYPE_FILEUPLOAD:
                     // An empty folder path has been posted, indicating that the
                     // current file should be removed
                     if (empty($value)) {
                         //echo("Empty value, deleting file...<br />");
                         if ($arrSettings[$name]['value']) {
                             if (\File::delete_file($arrSettings[$name]['value'])) {
                                 //echo("File deleted<br />");
                                 $value = '';
                             } else {
                                 //echo("Failed to delete file<br />");
                                 \Message::error(\File::getErrorString());
                                 $result = false;
                             }
                         }
                     } else {
                         // No file uploaded.  Skip.
                         if (empty($_FILES[$name]['name'])) {
                             continue;
                         }
                         // $value is the target folder path
                         $target_path = $value . '/' . $_FILES[$name]['name'];
                         // TODO: Test if this works in all browsers:
                         // The path input field name is the same as the
                         // file upload input field name!
                         $result_upload = \File::upload_file_http($name, $target_path, \Filetype::MAXIMUM_UPLOAD_FILE_SIZE, $arrSettings[$name]['values']);
                         // If no file has been uploaded at all, ignore the no-change
                         // TODO: Noop is not implemented in File::upload_file_http()
                         // if ($result_upload === '') continue;
                         if ($result_upload === true) {
                             $value = $target_path;
                         } else {
                             //echo("self::storeFromPost(): Error uploading file for setting $name to $target_path<br />");
                             // TODO: Add error message
                             \Message::error(\File::getErrorString());
                             $result = false;
                         }
                     }
                     break;
                 case self::TYPE_CHECKBOX:
                     break;
                 case self::TYPE_DROPDOWN_MULTISELECT:
                     $value = array_flip($value);
                 case self::TYPE_CHECKBOXGROUP:
                     $value = is_array($value) ? join(',', array_keys($value)) : $value;
                     // 20120508
                 // 20120508
                 case self::TYPE_RADIO:
                     break;
                 case self::TYPE_IMAGE:
                     $cx = \Cx\Core\Core\Controller\Cx::instanciate();
                     $options = json_decode($arrSettings[$name]['values'], true);
                     if ($options['type'] && $options['type'] == 'copy') {
                         \Cx\Lib\FileSystem\FileSystem::copy_file($cx->getWebsitePath() . $value, $cx->getWebsitePath() . '/' . $arrSettings[$name]['value'], true);
                         $value = $arrSettings[$name]['value'];
                     }
                     break;
                 default:
                     // Regular value of any other type
                     break;
             }
             //\DBG::log('setting value ' . $name . ' = ' . $value);
             self::set($name, $value);
         } elseif ($arrSettings[$name]['type'] == self::TYPE_CHECKBOX && $arrSettings[$name]['group'] == $submittedGroup) {
             self::set($name, null);
//.........这里部分代码省略.........
开发者ID:Cloudrexx,项目名称:cloudrexx,代码行数:101,代码来源:Setting.class.php


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