當前位置: 首頁>>代碼示例>>PHP>>正文


PHP LocalFile::moveTo方法代碼示例

本文整理匯總了PHP中LocalFile::moveTo方法的典型用法代碼示例。如果您正苦於以下問題:PHP LocalFile::moveTo方法的具體用法?PHP LocalFile::moveTo怎麽用?PHP LocalFile::moveTo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在LocalFile的用法示例。


在下文中一共展示了LocalFile::moveTo方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testMoveTo

 public function testMoveTo()
 {
     //existing file
     $this->assertTrue(is_file(TESTS_FSI_LOCALFILE_TMP_PATH . '/myFile.ext'));
     $this->assertFalse(is_file(TESTS_FSI_LOCALFILE_TMP_PATH . '/myDir/myFile.ext'));
     $originalContent = file_get_contents(TESTS_FSI_LOCALFILE_TMP_PATH . '/myFile.ext');
     $this->assertTrue($this->fixture_file->moveTo($this->fixture_dir));
     $this->assertFalse(is_file(TESTS_FSI_LOCALFILE_TMP_PATH . '/myFile.ext'));
     $this->assertTrue(is_file(TESTS_FSI_LOCALFILE_TMP_PATH . '/myDir/myFile.ext'));
     $this->assertEquals($originalContent, file_get_contents(TESTS_FSI_LOCALFILE_TMP_PATH . '/myDir/myFile.ext'));
     unlink(TESTS_FSI_LOCALFILE_TMP_PATH . '/myDir/myFile.ext');
     //non-existing file
     $this->assertFalse(is_file(TESTS_FSI_LOCALFILE_TMP_PATH . '/myFile.ext'));
     try {
         $this->fixture_file->moveTo($this->fixture_dir);
         $fail->fail();
     } catch (EyeFileNotFoundException $e) {
         // normal situation
     }
     //existing directory containing files
     mkdir(TESTS_FSI_LOCALFILE_TMP_PATH . '/dir1');
     $dir = new LocalFile(TESTS_FSI_LOCALFILE_TMP_PATH . '/dir1');
     $originalContent = '## test - content ##';
     file_put_contents(TESTS_FSI_LOCALFILE_TMP_PATH . '/dir1/mySubFile.ext', $originalContent);
     $this->assertTrue(is_dir(TESTS_FSI_LOCALFILE_TMP_PATH . '/dir1'));
     $this->assertTrue(is_file(TESTS_FSI_LOCALFILE_TMP_PATH . '/dir1/mySubFile.ext'));
     $this->assertTrue($dir->moveTo($this->fixture_dir));
     $this->assertFalse(is_dir(TESTS_FSI_LOCALFILE_TMP_PATH . '/dir1'));
     $this->assertTrue(is_dir(TESTS_FSI_LOCALFILE_TMP_PATH . '/myDir/dir1'));
     $this->assertTrue(is_file(TESTS_FSI_LOCALFILE_TMP_PATH . '/myDir/dir1/mySubFile.ext'));
     $this->assertEquals($originalContent, file_get_contents(TESTS_FSI_LOCALFILE_TMP_PATH . '/myDir/dir1/mySubFile.ext'));
     unlink(TESTS_FSI_LOCALFILE_TMP_PATH . '/myDir/dir1/mySubFile.ext');
     rmdir(TESTS_FSI_LOCALFILE_TMP_PATH . '/myDir/dir1');
 }
開發者ID:DavidGarciaCat,項目名稱:eyeos,代碼行數:34,代碼來源:LocalFileTest.php

示例2: submitFile

 public static function submitFile($path)
 {
     try {
         if (!isset($_FILES['Filedata'])) {
             echo '<div style="font-size:20px;font-family:Helvetica, Arial, Verdana, Sans, FreeSans;margin-top:80px;margin-right:15px;"><center>&nbsp;&nbsp;<img style="position:relative;top:15px"src="index.php?extern=/images/48x48/actions/dialog-close.png" />Error uploading files</center>';
             exit;
         }
         $Logger = Logger::getLogger('application.upload');
         foreach ($_FILES['Filedata']['name'] as $k => $v) {
             if (!empty($v)) {
                 $filename = $_FILES['Filedata']['name'][$k];
                 if (!isset($_POST['UPLOAD_IDENTIFIER'])) {
                     $filename = utf8_encode($filename);
                 }
                 $tmpPath = $_FILES['Filedata']['tmp_name'][$k];
                 $Logger->debug("Filename: " . $filename);
                 if (!is_uploaded_file($tmpPath)) {
                     throw new EyeFileNotFoundException('Uploaded file not found at "' . $tmpPath . '".');
                 }
                 $request = MMapManager::getCurrentRequest();
                 $destPath = $path;
                 $filename = str_replace('?', '_', $filename);
                 $filename = str_replace('#', '_', $filename);
                 $tmp = pathinfo($filename);
                 if (isset($tmp['extension']) && "lnk" == $tmp['extension']) {
                     throw new EyeFileNotFoundException('This file cannot be uploaded (file type banned)');
                 }
                 /*
                 if ( '?' == $filename{0} ) {
                 	$filename{0} = "_";
                 }
                 */
                 $destFile = FSI::getFile($destPath . '/' . $filename);
                 //The uploaded file is necessarily on the local filesystem and we want to avoid any
                 //permission check through EyeLocalFile, so we use LocalFile directly
                 $tmpFile = new LocalFile($tmpPath);
                 $num = 1;
                 $extension = AdvancedPathLib::pathinfo($filename, PATHINFO_EXTENSION);
                 $filename = AdvancedPathLib::pathinfo($filename, PATHINFO_FILENAME);
                 $Logger->debug("CLASS: " . get_class($destFile));
                 $Logger->debug("Exists: " . $destFile->exists());
                 //exit();
                 while ($destFile->exists()) {
                     $newBasename = $filename . ' (' . $num++ . ')' . ($extension ? '.' . $extension : '');
                     $destFile = FSI::getFile($destPath . '/' . $newBasename);
                 }
                 $destFile->checkWritePermission();
                 $tmpFile->moveTo($destFile);
                 $currentUser = ProcManager::getInstance()->getCurrentProcess()->getLoginContext()->getEyeosUser();
                 $settings = MetaManager::getInstance()->retrieveMeta($currentUser);
                 $message = new ClientBusMessage('file', 'uploadComplete', self::getFileInfo($destFile, $settings));
                 ClientMessageBusController::getInstance()->queueMessage($message);
                 $event = new FileEvent($destFile);
                 $destFile->fireEvent('fileWritten', $event);
             }
         }
         register_shutdown_function('endRequestUpload');
     } catch (EyeException $e) {
         echo '<div style="font-size:20px;font-family:Helvetica, Arial, Verdana, Sans, FreeSans;margin-top:80px;margin-right:15px;"><center>&nbsp;&nbsp;<img style="position:relative;top:15px"src="index.php?extern=/images/48x48/actions/dialog-close.png" />Error uploading files: ' . $e->getMessage() . '</center>';
         exit;
     }
 }
開發者ID:sebasalons,項目名稱:eyeos-u1db,代碼行數:62,代碼來源:upload.php

示例3: moveTo

 /**
  * @return bool TRUE if the file has been successfully moved, FALSE otherwise
  */
 public function moveTo(IFile $file)
 {
     $this->getParentFile()->checkWritePermission();
     $this->checkReadPermission();
     return parent::moveTo($file);
 }
開發者ID:DavidGarciaCat,項目名稱:eyeos,代碼行數:9,代碼來源:LocalFile.php


注:本文中的LocalFile::moveTo方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。