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


PHP GeneralUtility::fixWindowsFilePath方法代码示例

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


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

示例1: tearDown

 /**
  * Unset all additional properties of test classes to help PHP
  * garbage collection. This reduces memory footprint with lots
  * of tests.
  *
  * If owerwriting tearDown() in test classes, please call
  * parent::tearDown() at the end. Unsetting of own properties
  * is not needed this way.
  *
  * @throws \RuntimeException
  * @return void
  */
 protected function tearDown()
 {
     // Unset properties of test classes to safe memory
     $reflection = new \ReflectionObject($this);
     foreach ($reflection->getProperties() as $property) {
         $declaringClass = $property->getDeclaringClass()->getName();
         if (!$property->isStatic() && $declaringClass !== \TYPO3\CMS\Core\Tests\UnitTestCase::class && $declaringClass !== \TYPO3\CMS\Core\Tests\BaseTestCase::class && strpos($property->getDeclaringClass()->getName(), 'PHPUnit_') !== 0) {
             $propertyName = $property->getName();
             unset($this->{$propertyName});
         }
     }
     unset($reflection);
     // Delete registered test files and directories
     foreach ($this->testFilesToDelete as $absoluteFileName) {
         $absoluteFileName = GeneralUtility::fixWindowsFilePath(PathUtility::getCanonicalPath($absoluteFileName));
         if (!GeneralUtility::validPathStr($absoluteFileName)) {
             throw new \RuntimeException('tearDown() cleanup: Filename contains illegal characters', 1410633087);
         }
         if (!StringUtility::beginsWith($absoluteFileName, PATH_site . 'typo3temp/')) {
             throw new \RuntimeException('tearDown() cleanup:  Files to delete must be within typo3temp/', 1410633412);
         }
         // file_exists returns false for links pointing to not existing targets, so handle links before next check.
         if (@is_link($absoluteFileName) || @is_file($absoluteFileName)) {
             unlink($absoluteFileName);
         } elseif (@is_dir($absoluteFileName)) {
             GeneralUtility::rmdir($absoluteFileName, true);
         } else {
             throw new \RuntimeException('tearDown() cleanup: File, link or directory does not exist', 1410633510);
         }
     }
     $this->testFilesToDelete = array();
 }
开发者ID:rickymathew,项目名称:TYPO3.CMS,代码行数:44,代码来源:UnitTestCase.php

示例2: execute

 /**
  * @return FlashMessage
  */
 public function execute()
 {
     $this->controller->headerMessage(LocalizationUtility::translate('moveDamRecordsToStorageCommand', 'dam_falmigration', array($this->storageObject->getName())));
     if (!$this->isTableAvailable('tx_dam')) {
         return $this->getResultMessage('damTableNotFound');
     }
     $this->fileIndexRepository = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\Index\\FileIndexRepository');
     $result = $this->execSelectNotMigratedDamRecordsQuery();
     $counter = 0;
     $total = $this->database->sql_num_rows($result);
     $this->controller->infoMessage('Found ' . $total . ' DAM records without a connection to a sys_file storage');
     $relativeTargetFolderBasePath = $this->storageBasePath . $this->targetFolderBasePath;
     while ($damRecord = $this->database->sql_fetch_assoc($result)) {
         $counter++;
         try {
             $relativeSourceFilePath = GeneralUtility::fixWindowsFilePath($this->getFullFileName($damRecord));
             $absoluteSourceFilePath = PATH_site . $relativeSourceFilePath;
             if (!file_exists($absoluteSourceFilePath)) {
                 throw new \RuntimeException('No file found for DAM record. DAM uid: ' . $damRecord['uid'] . ': "' . $relativeSourceFilePath . '"', 1441110613);
             }
             list($_, $directory) = explode('/', dirname($relativeSourceFilePath), 2);
             $relativeTargetFolder = $relativeTargetFolderBasePath . rtrim($directory, '/') . '/';
             $absoluteTargetFolder = PATH_site . $relativeTargetFolder;
             if (!is_dir($absoluteTargetFolder)) {
                 GeneralUtility::mkdir_deep($absoluteTargetFolder);
             }
             $basename = basename($relativeSourceFilePath);
             $absoluteTargetFilePath = $absoluteTargetFolder . $basename;
             if (!file_exists($absoluteTargetFilePath)) {
                 GeneralUtility::upload_copy_move($absoluteSourceFilePath, $absoluteTargetFilePath);
             } elseif (filesize($absoluteSourceFilePath) !== filesize($absoluteTargetFilePath)) {
                 throw new \RuntimeException('File already exists. DAM uid: ' . $damRecord['uid'] . ': "' . $relativeSourceFilePath . '"', 1441112138);
             }
             $fileIdentifier = substr($relativeTargetFolder, strlen($this->storageBasePath)) . $basename;
             $fileObject = $this->storageObject->getFile($fileIdentifier);
             $this->fileIndexRepository->add($fileObject);
             $this->updateDamFilePath($damRecord['uid'], $relativeTargetFolder);
             $this->amountOfMigratedRecords++;
         } catch (\Exception $e) {
             $this->setDamFileMissingByUid($damRecord['uid']);
             $this->controller->warningMessage($e->getMessage());
             $this->amountOfFilesNotFound++;
             continue;
         }
     }
     $this->database->sql_free_result($result);
     $this->controller->message('Not migrated dam records at start of task: ' . $total . '. Migrated files after task: ' . $this->amountOfMigratedRecords . '. Files not found: ' . $this->amountOfFilesNotFound . '.');
     return $this->getResultMessage();
 }
开发者ID:r3h6,项目名称:t3ext-dam_falmigration,代码行数:52,代码来源:MigrateToStorageService.php

示例3: translatePath

 /**
  * Translates an array of paths or single path into absolute paths/path
  *
  * @param mixed $path
  * @return mixed
  */
 public static function translatePath($path)
 {
     if (is_array($path) == FALSE) {
         $path = 0 === strpos($path, '/') ? $path : GeneralUtility::getFileAbsFileName($path);
         if (is_dir($path)) {
             $path = realpath($path) . '/';
         }
         $path = GeneralUtility::fixWindowsFilePath($path);
     } else {
         foreach ($path as $key => $subPath) {
             if (TRUE === in_array($key, self::$knownPathNames)) {
                 $path[$key] = self::translatePath($subPath);
             }
         }
     }
     return $path;
 }
开发者ID:neufeind,项目名称:flux,代码行数:23,代码来源:PathUtility.php

示例4: cleanUpPath

 /**
  * Consolidate between Windows and Unix and add trailing slash im missing
  *
  * @param string $path Given path
  * @return string Cleaned up path
  */
 protected function cleanUpPath($path)
 {
     $path = \TYPO3\CMS\Core\Utility\GeneralUtility::fixWindowsFilePath($path);
     // Add trailing slash if missing
     if (!preg_match('/[\\/]$/', $path)) {
         $path .= '/';
     }
     return $path;
 }
开发者ID:plan2net,项目名称:TYPO3.CMS,代码行数:15,代码来源:AbstractImagePreset.php

示例5: renderExecutablesSearchPathList

    /**
     * This method assembles a list of all defined executables search paths
     *
     * @return string HTML to display
     */
    protected function renderExecutablesSearchPathList()
    {
        $searchPaths = \TYPO3\CMS\Core\Utility\CommandUtility::getPaths(TRUE);
        $content = '<br /><h3 class="divider">' . $GLOBALS['LANG']->getLL('search_paths') . '</h3>';
        if (count($searchPaths) == 0) {
            $content .= '<p>' . $GLOBALS['LANG']->getLL('no_search_paths') . '</p>';
        } else {
            $content .= '
			<table cellspacing="1" cellpadding="2" border="0" class="tx_sv_reportlist paths">
				<thead>
					<tr class="t3-row-header">
						<td>' . $GLOBALS['LANG']->getLL('path') . '</td>
						<td>' . $GLOBALS['LANG']->getLL('valid') . '</td>
					</tr>
				</thead>
				<tbody>';
            foreach ($searchPaths as $path => $isValid) {
                $pathAccessibleClass = 'typo3-message message-error';
                $pathAccessible = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:no');
                if ($isValid) {
                    $pathAccessibleClass = 'typo3-message message-ok';
                    $pathAccessible = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:yes');
                }
                $content .= '
					<tr>
						<td class="first-cell ' . $pathAccessibleClass . '">' . \TYPO3\CMS\Core\Utility\GeneralUtility::fixWindowsFilePath($path) . '</td>
						<td class="last-cell ' . $pathAccessibleClass . '">' . $pathAccessible . '</td>
					</tr>';
            }
            $content .= '
				</tbody>
			</table>';
        }
        return $content;
    }
开发者ID:noxludo,项目名称:TYPO3v4-Core,代码行数:40,代码来源:ServicesListReport.php

示例6: expandPatterns

 /**
  * Expands the given $patterns by adding an array element for each $replacement
  * replacing occurrences of $search.
  *
  * @param array $patterns
  * @param string $search
  * @param array $replacements
  * @return void
  */
 protected function expandPatterns(array &$patterns, $search, array $replacements)
 {
     $patternsWithReplacements = array();
     foreach ($patterns as $pattern) {
         foreach ($replacements as $replacement) {
             $patternsWithReplacements[] = GeneralUtility::fixWindowsFilePath(str_replace($search, $replacement, $pattern));
         }
     }
     $patterns = $patternsWithReplacements;
 }
开发者ID:Mr-Robota,项目名称:TYPO3.CMS,代码行数:19,代码来源:TemplateView.php

示例7: getPartialPathAndFilename

 /**
  * Resolve the partial path and filename based on $this->getPartialRootPath() and request format
  *
  * @param string $partialName The name of the partial
  * @return string the full path which should be used. The path definitely exists.
  * @throws \TYPO3\CMS\Fluid\View\Exception\InvalidTemplateResourceException
  */
 protected function getPartialPathAndFilename($partialName)
 {
     $partialRootPath = $this->getPartialRootPath();
     if (!is_dir($partialRootPath)) {
         throw new \TYPO3\CMS\Fluid\View\Exception\InvalidTemplateResourceException('Partial root path "' . $partialRootPath . '" does not exist.', 1288094648);
     }
     $possiblePartialPaths = array();
     $possiblePartialPaths[] = \TYPO3\CMS\Core\Utility\GeneralUtility::fixWindowsFilePath($partialRootPath . '/' . $partialName . '.' . $this->getRequest()->getFormat());
     $possiblePartialPaths[] = \TYPO3\CMS\Core\Utility\GeneralUtility::fixWindowsFilePath($partialRootPath . '/' . $partialName);
     foreach ($possiblePartialPaths as $partialPathAndFilename) {
         if (is_file($partialPathAndFilename)) {
             return $partialPathAndFilename;
         }
     }
     throw new \TYPO3\CMS\Fluid\View\Exception\InvalidTemplateResourceException('Could not load partial file. Tried following paths: "' . implode('", "', $possiblePartialPaths) . '".', 1288092556);
 }
开发者ID:samuweiss,项目名称:TYPO3-Site,代码行数:23,代码来源:StandaloneView.php

示例8: renameFile

 /**
  * Renames a file in this storage.
  *
  * @param string $fileIdentifier
  * @param string $newName The target path (including the file name!)
  * @return string The identifier of the file after renaming
  * @throws Exception\ExistingTargetFileNameException
  * @throws \RuntimeException
  */
 public function renameFile($fileIdentifier, $newName)
 {
     // Makes sure the Path given as parameter is valid
     $newName = $this->sanitizeFileName($newName);
     $newIdentifier = rtrim(GeneralUtility::fixWindowsFilePath(PathUtility::dirname($fileIdentifier)), '/') . '/' . $newName;
     $newIdentifier = $this->canonicalizeAndCheckFileIdentifier($newIdentifier);
     // The target should not exist already
     if ($this->fileExists($newIdentifier)) {
         throw new Exception\ExistingTargetFileNameException('The target file "' . $newIdentifier . '" already exists.', 1320291063);
     }
     $sourcePath = $this->getAbsolutePath($fileIdentifier);
     $targetPath = $this->getAbsolutePath($newIdentifier);
     $result = rename($sourcePath, $targetPath);
     if ($result === false) {
         throw new \RuntimeException('Renaming file ' . $sourcePath . ' to ' . $targetPath . ' failed.', 1320375115);
     }
     return $newIdentifier;
 }
开发者ID:graurus,项目名称:testgit_t37,代码行数:27,代码来源:LocalDriver.php

示例9: makePathRelative

 /**
  * Generate a relative path string from an absolute path within a give package path
  *
  * @param string $packagePath
  * @param string $realPathOfClassFile
  * @return string
  */
 protected static function makePathRelative($packagePath, $realPathOfClassFile)
 {
     $realPathOfClassFile = GeneralUtility::fixWindowsFilePath($realPathOfClassFile);
     $classesRealPath = GeneralUtility::fixWindowsFilePath(realpath($packagePath));
     $relativeClassesPath = rtrim(PathUtility::stripPathSitePrefix($packagePath), '/');
     $relativePathToClassFile = $relativeClassesPath . '/' . ltrim(substr($realPathOfClassFile, strlen($classesRealPath)), '/');
     return $relativePathToClassFile;
 }
开发者ID:adrolli,项目名称:TYPO3.CMS,代码行数:15,代码来源:ClassLoadingInformationGenerator.php

示例10: getPartialPathAndFilename

 /**
  * Resolve the partial path and filename based on $this->getPartialRootPaths() and request format
  *
  * @param string $partialName The name of the partial
  * @return string The full path which should be used. The path definitely exists.
  * @throws InvalidTemplateResourceException
  */
 protected function getPartialPathAndFilename($partialName)
 {
     $upperCasedPartialName = ucfirst($partialName);
     $paths = ArrayUtility::sortArrayWithIntegerKeys($this->getPartialRootPaths());
     $paths = array_reverse($paths, TRUE);
     $possiblePartialPaths = array();
     foreach ($paths as $partialRootPath) {
         $possiblePartialPaths[] = GeneralUtility::fixWindowsFilePath($partialRootPath . '/' . $upperCasedPartialName . '.' . $this->getRequest()->getFormat());
         $possiblePartialPaths[] = GeneralUtility::fixWindowsFilePath($partialRootPath . '/' . $upperCasedPartialName);
         if ($upperCasedPartialName !== $partialName) {
             $possiblePartialPaths[] = GeneralUtility::fixWindowsFilePath($partialRootPath . '/' . $partialName . '.' . $this->getRequest()->getFormat());
             $possiblePartialPaths[] = GeneralUtility::fixWindowsFilePath($partialRootPath . '/' . $partialName);
         }
     }
     foreach ($possiblePartialPaths as $partialPathAndFilename) {
         if ($this->testFileExistence($partialPathAndFilename)) {
             return $partialPathAndFilename;
         }
     }
     throw new InvalidTemplateResourceException('Could not load partial file. Tried following paths: "' . implode('", "', $possiblePartialPaths) . '".', 1288092556);
 }
开发者ID:khanhdeux,项目名称:typo3test,代码行数:28,代码来源:StandaloneView.php

示例11: checkValue_group_select_file

 /**
  * Handling files for group/select function
  *
  * @param array $valueArray Array of incoming file references. Keys are numeric, values are files (basically, this is the exploded list of incoming files)
  * @param array $tcaFieldConf Configuration array from TCA of the field
  * @param string $curValue Current value of the field
  * @param array $uploadedFileArray Array of uploaded files, if any
  * @param string $status 'update' or 'new' flag
  * @param string $table tablename of record
  * @param int $id UID of record
  * @param string $recFID Field identifier [table:uid:field] for flexforms
  * @return array Modified value array
  *
  * @throws \RuntimeException
  * @see checkValue_group_select()
  */
 public function checkValue_group_select_file($valueArray, $tcaFieldConf, $curValue, $uploadedFileArray, $status, $table, $id, $recFID)
 {
     // If file handling should NOT be bypassed, do processing:
     if (!$this->bypassFileHandling) {
         // If any files are uploaded, add them to value array
         // Numeric index means that there are multiple files
         if (isset($uploadedFileArray[0])) {
             $uploadedFiles = $uploadedFileArray;
         } else {
             // There is only one file
             $uploadedFiles = array($uploadedFileArray);
         }
         foreach ($uploadedFiles as $uploadedFileArray) {
             if (!empty($uploadedFileArray['name']) && $uploadedFileArray['tmp_name'] !== 'none') {
                 $valueArray[] = $uploadedFileArray['tmp_name'];
                 $this->alternativeFileName[$uploadedFileArray['tmp_name']] = $uploadedFileArray['name'];
             }
         }
         // Creating fileFunc object.
         if (!$this->fileFunc) {
             $this->fileFunc = GeneralUtility::makeInstance(BasicFileUtility::class);
             $this->include_filefunctions = 1;
         }
         // Setting permitted extensions.
         $all_files = array();
         $all_files['webspace']['allow'] = $tcaFieldConf['allowed'];
         $all_files['webspace']['deny'] = $tcaFieldConf['disallowed'] ?: '*';
         $all_files['ftpspace'] = $all_files['webspace'];
         $this->fileFunc->init('', $all_files);
     }
     // If there is an upload folder defined:
     if ($tcaFieldConf['uploadfolder'] && $tcaFieldConf['internal_type'] == 'file') {
         $currentFilesForHistory = null;
         // If filehandling should NOT be bypassed, do processing:
         if (!$this->bypassFileHandling) {
             // For logging..
             $propArr = $this->getRecordProperties($table, $id);
             // Get destrination path:
             $dest = $this->destPathFromUploadFolder($tcaFieldConf['uploadfolder']);
             // If we are updating:
             if ($status == 'update') {
                 // Traverse the input values and convert to absolute filenames in case the update happens to an autoVersionized record.
                 // Background: This is a horrible workaround! The problem is that when a record is auto-versionized the files of the record get copied and therefore get new names which is overridden with the names from the original record in the incoming data meaning both lost files and double-references!
                 // The only solution I could come up with (except removing support for managing files when autoversioning) was to convert all relative files to absolute names so they are copied again (and existing files deleted). This should keep references intact but means that some files are copied, then deleted after being copied _again_.
                 // Actually, the same problem applies to database references in case auto-versioning would include sub-records since in such a case references are remapped - and they would be overridden due to the same principle then.
                 // Illustration of the problem comes here:
                 // We have a record 123 with a file logo.gif. We open and edit the files header in a workspace. So a new version is automatically made.
                 // The versions uid is 456 and the file is copied to "logo_01.gif". But the form data that we sent was based on uid 123 and hence contains the filename "logo.gif" from the original.
                 // The file management code below will do two things: First it will blindly accept "logo.gif" as a file attached to the record (thus creating a double reference) and secondly it will find that "logo_01.gif" was not in the incoming filelist and therefore should be deleted.
                 // If we prefix the incoming file "logo.gif" with its absolute path it will be seen as a new file added. Thus it will be copied to "logo_02.gif". "logo_01.gif" will still be deleted but since the files are the same the difference is zero - only more processing and file copying for no reason. But it will work.
                 if ($this->autoVersioningUpdate === true) {
                     foreach ($valueArray as $key => $theFile) {
                         // If it is an already attached file...
                         if ($theFile === basename($theFile)) {
                             $valueArray[$key] = PATH_site . $tcaFieldConf['uploadfolder'] . '/' . $theFile;
                         }
                     }
                 }
                 // Finding the CURRENT files listed, either from MM or from the current record.
                 $theFileValues = array();
                 // If MM relations for the files also!
                 if ($tcaFieldConf['MM']) {
                     $dbAnalysis = $this->createRelationHandlerInstance();
                     /** @var $dbAnalysis RelationHandler */
                     $dbAnalysis->start('', 'files', $tcaFieldConf['MM'], $id);
                     foreach ($dbAnalysis->itemArray as $item) {
                         if ($item['id']) {
                             $theFileValues[] = $item['id'];
                         }
                     }
                 } else {
                     $theFileValues = GeneralUtility::trimExplode(',', $curValue, true);
                 }
                 $currentFilesForHistory = implode(',', $theFileValues);
                 // DELETE files: If existing files were found, traverse those and register files for deletion which has been removed:
                 if (!empty($theFileValues)) {
                     // Traverse the input values and for all input values which match an EXISTING value, remove the existing from $theFileValues array (this will result in an array of all the existing files which should be deleted!)
                     foreach ($valueArray as $key => $theFile) {
                         if ($theFile && !strstr(GeneralUtility::fixWindowsFilePath($theFile), '/')) {
                             $theFileValues = ArrayUtility::removeArrayEntryByValue($theFileValues, $theFile);
                         }
                     }
                     // This array contains the filenames in the uploadfolder that should be deleted:
                     foreach ($theFileValues as $key => $theFile) {
//.........这里部分代码省略.........
开发者ID:rickymathew,项目名称:TYPO3.CMS,代码行数:101,代码来源:DataHandler.php

示例12: setCacheDirectoryAllowsRelativeDottedPathWithTrailingSlash

 /**
  * @test
  */
 public function setCacheDirectoryAllowsRelativeDottedPathWithTrailingSlash()
 {
     $backend = $this->getAccessibleMock(\TYPO3\CMS\Core\Cache\Backend\FileBackend::class, array('dummy'), array(), '', false);
     $backend->_set('cacheIdentifier', 'test');
     $backend->setCacheDirectory('../tmp/foo/');
     // get PATH_site without trailing slash
     $path = GeneralUtility::fixWindowsFilePath(realpath(PATH_site));
     $this->assertEquals($path . '/../tmp/foo/test/', $backend->_get('temporaryCacheDirectory'));
 }
开发者ID:TYPO3Incubator,项目名称:TYPO3.CMS,代码行数:12,代码来源:FileBackendTest.php

示例13: saveUploadedFile

 /**
  * Save a uploaded file
  *
  * @param string $uploadedFile
  * @return NULL|string
  */
 public function saveUploadedFile($uploadedFile)
 {
     if (is_uploaded_file($uploadedFile)) {
         $tempFilename = GeneralUtility::upload_to_tempfile($uploadedFile);
         if (TYPO3_OS === 'WIN') {
             $tempFilename = GeneralUtility::fixWindowsFilePath($tempFilename);
         }
         if ($tempFilename !== '') {
             return $tempFilename;
         }
     }
     return null;
 }
开发者ID:hlop,项目名称:TYPO3.CMS,代码行数:19,代码来源:HandleIncomingFormValues.php

示例14: storeFiles

 /**
  * Store uploaded files in the typo3temp and return the information of those
  * files
  *
  * @return void
  */
 public function storeFiles()
 {
     $formData = $this->getByMethod();
     if (isset($_FILES[$this->prefix]) && is_array($_FILES[$this->prefix])) {
         foreach ($_FILES[$this->prefix]['tmp_name'] as $fieldName => $uploadedFile) {
             if (is_uploaded_file($uploadedFile)) {
                 $tempFilename = GeneralUtility::upload_to_tempfile($uploadedFile);
                 if (TYPO3_OS === 'WIN') {
                     $tempFilename = GeneralUtility::fixWindowsFilePath($tempFilename);
                 }
                 if ($tempFilename !== '') {
                     $fileInfo = GeneralUtility::makeInstance(FileInfo::class, $tempFilename);
                     $formData[$fieldName] = array('tempFilename' => $tempFilename, 'originalFilename' => $_FILES[$this->prefix]['name'][$fieldName], 'type' => $fileInfo->getMimeType(), 'size' => (int) $_FILES[$this->prefix]['size'][$fieldName]);
                 }
             }
         }
     }
     switch ($this->getMethod()) {
         case 'post':
             $_POST[$this->prefix] = $formData;
             break;
         case 'get':
             $_GET[$this->prefix] = $formData;
             break;
         case 'session':
             $this->sessionData = $formData;
             break;
     }
 }
开发者ID:plan2net,项目名称:TYPO3.CMS,代码行数:35,代码来源:Request.php

示例15: storeFiles

 /**
  * Store uploaded files in the typo3temp and return the information of those
  * files
  *
  * @return void
  */
 public function storeFiles()
 {
     $formData = $this->getByMethod();
     if (isset($_FILES[$this->prefix]) && is_array($_FILES[$this->prefix])) {
         foreach ($_FILES[$this->prefix]['tmp_name'] as $fieldName => $uploadedFile) {
             if (is_uploaded_file($uploadedFile)) {
                 $tempFilename = \TYPO3\CMS\Core\Utility\GeneralUtility::upload_to_tempfile($uploadedFile);
                 if (TYPO3_OS === 'WIN') {
                     $tempFilename = \TYPO3\CMS\Core\Utility\GeneralUtility::fixWindowsFilePath($tempFilename);
                 }
                 if ($tempFilename !== '') {
                     // Use finfo to get the mime type
                     $finfo = finfo_open(FILEINFO_MIME_TYPE);
                     $mimeType = finfo_file($finfo, $tempFilename);
                     finfo_close($finfo);
                     $formData[$fieldName] = array('tempFilename' => $tempFilename, 'originalFilename' => $_FILES[$this->prefix]['name'][$fieldName], 'type' => $mimeType, 'size' => (int) $_FILES[$this->prefix]['size'][$fieldName]);
                 }
             }
         }
     }
     switch ($this->getMethod()) {
         case 'post':
             $_POST[$this->prefix] = $formData;
             break;
         case 'get':
             $_GET[$this->prefix] = $formData;
             break;
         case 'session':
             $this->sessionData = $formData;
             break;
     }
 }
开发者ID:khanhdeux,项目名称:typo3test,代码行数:38,代码来源:Request.php


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