86 'renameFile' =>
false,
87 'deleteFile' =>
false,
90 'readFolder' =>
false,
91 'writeFolder' =>
false,
92 'copyFolder' =>
false,
93 'moveFolder' =>
false,
94 'renameFolder' =>
false,
95 'deleteFolder' =>
false,
96 'recursivedeleteFolder' => false
155 'Invalid argument, received: "%s", expected a value from enumeration \TYPO3\CMS\Core\Resource\DuplicationBehavior (%s)',
169 public function start($fileCmds)
174 $this->fileCmdMap = $fileCmds;
185 if (empty($permissions)) {
188 $this->actionPerms = $permissions;
200 if (is_array($this->fileCmdMap)) {
202 if ($this->fileCmdMap[
'upload']) {
203 $uploads = $this->fileCmdMap[
'upload'];
204 foreach ($uploads as $upload) {
205 if (empty($_FILES[
'upload_' . $upload[
'data']][
'name'])
207 is_array($_FILES[
'upload_' . $upload[
'data']][
'name'])
208 && empty($_FILES[
'upload_' . $upload[
'data']][
'name'][0])
211 unset($this->fileCmdMap[
'upload'][$upload[
'data']]);
214 if (empty($this->fileCmdMap[
'upload'])) {
215 $this->
writeLog(1, 1, 108,
'No file was uploaded!', []);
221 if ($this->fileCmdMap[
'newfolder']) {
222 foreach ($this->fileCmdMap[
'newfolder'] as $key => $cmdArr) {
223 if (empty($cmdArr[
'data'])) {
224 unset($this->fileCmdMap[
'newfolder'][$key]);
227 if (empty($this->fileCmdMap[
'newfolder'])) {
228 $this->
writeLog(6, 1, 108,
'No name for new folder given!', []);
234 foreach ($this->fileCmdMap as $action => $actionData) {
236 if (is_array($actionData)) {
237 $result[$action] = [];
238 foreach ($actionData as $cmdArr) {
247 $result[$action][] = $this->
func_copy($cmdArr);
250 $result[$action][] = $this->
func_move($cmdArr);
262 $result[$action][] = $this->
func_edit($cmdArr);
272 foreach (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_extfilefunc.php'][
'processData'] ?? [] as $className) {
273 $hookObject = GeneralUtility::makeInstance($className);
275 throw new \UnexpectedValueException($className .
' must implement interface ' . ExtendedFileUtilityProcessDataHookInterface::class, 1279719168);
277 $hookObject->processData_postProcessAction($action, $cmdArr, $result[$action], $this);
303 public function writeLog($action, $error, $details_nr, $details, $data)
308 $this->
getBackendUser()->writelog($type, $action, $error, $details_nr, $details, $data);
311 $this->errorMessages[] = vsprintf($details, $data);
325 if (TYPO3_MODE !==
'BE') {
328 $label = $this->
getLanguageService()->
sL(
'LLL:EXT:core/Resources/Private/Language/fileMessages.xlf:' . $localizationKey);
329 $message = vsprintf($label, $replaceMarkers);
330 $flashMessage = GeneralUtility::makeInstance(
359 $flashMessage = GeneralUtility::makeInstance(
362 $this->
getLanguageService()->sL(
'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:message.description.fileNotFound'),
365 $this->
getLanguageService()->sL(
'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:message.header.fileNotFound'),
374 if ($fileObject instanceof
File) {
377 $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable(
'sys_refindex');
378 $queryBuilder->getRestrictions()->removeAll()->add(GeneralUtility::makeInstance(DeletedRestriction::class));
379 $refIndexRecords = $queryBuilder
380 ->select(
'tablename',
'recuid',
'ref_uid')
381 ->from(
'sys_refindex')
383 $queryBuilder->expr()->eq(
385 $queryBuilder->createNamedParameter(
'sys_file', \PDO::PARAM_STR)
387 $queryBuilder->expr()->eq(
389 $queryBuilder->createNamedParameter($fileObject->getUid(), \PDO::PARAM_INT)
391 $queryBuilder->expr()->neq(
393 $queryBuilder->createNamedParameter(
'sys_file_metadata', \PDO::PARAM_STR)
395 $queryBuilder->expr()->eq(
397 $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)
403 if (!empty($refIndexRecords)) {
404 $shortcutContent = [];
405 $brokenReferences = [];
407 foreach ($refIndexRecords as $fileReferenceRow) {
408 if ($fileReferenceRow[
'tablename'] ===
'sys_file_reference') {
412 if ($shortcutRecord) {
413 $shortcutContent[] =
'[record:' . $row[
'tablename'] .
':' . $row[
'recuid'] .
']';
415 $brokenReferences[] = $fileReferenceRow[
'ref_uid'];
418 $shortcutContent[] =
'[record:' . $fileReferenceRow[
'tablename'] .
':' . $fileReferenceRow[
'recuid'] .
']';
421 if (!empty($brokenReferences)) {
423 $flashMessage = GeneralUtility::makeInstance(
425 sprintf($this->
getLanguageService()->sL(
'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:message.description.fileHasBrokenReferences'), count($brokenReferences)),
426 $this->
getLanguageService()->sL(
'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:message.header.fileHasBrokenReferences'),
432 if (!empty($shortcutContent)) {
434 $flashMessage = GeneralUtility::makeInstance(
436 sprintf($this->
getLanguageService()->sL(
'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:message.description.fileNotDeletedHasReferences'), $fileObject->getName()) .
' ' . implode(
', ', $shortcutContent),
437 $this->
getLanguageService()->sL(
'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:message.header.fileNotDeletedHasReferences'),
448 $result = $fileObject->delete();
451 $flashMessage = GeneralUtility::makeInstance(
453 sprintf($this->
getLanguageService()->sL(
'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:message.description.fileDeleted'), $fileObject->getName()),
454 $this->getLanguageService()->sL(
'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:message.header.fileDeleted'),
460 $this->
writeLog(4, 0, 1,
'File "%s" deleted', [$fileObject->getIdentifier()]);
462 $this->
writeLog(4, 1, 112,
'You are not allowed to access the file', [$fileObject->getIdentifier()]);
465 $this->
writeLog(4, 1, 111,
'Target was not within your mountpoints! T="%s"', [$fileObject->getIdentifier()]);
467 }
catch (\RuntimeException $e) {
468 $this->
writeLog(4, 1, 110,
'Could not delete file "%s". Write-permission problem?', [$fileObject->getIdentifier()]);
476 $result = $fileObject->delete(
true);
480 $flashMessage = GeneralUtility::makeInstance(
482 sprintf($this->
getLanguageService()->sL(
'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:message.description.folderDeleted'), $fileObject->getName()),
483 $this->getLanguageService()->sL(
'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:message.header.folderDeleted'),
489 $this->
writeLog(4, 0, 3,
'Directory "%s" deleted', [$fileObject->getIdentifier()]);
492 $this->
writeLog(4, 1, 120,
'Could not delete directory! Is directory "%s" empty? (You are not allowed to delete directories recursively).', [$fileObject->getIdentifier()]);
495 $this->
writeLog(4, 1, 123,
'You are not allowed to access the directory', [$fileObject->getIdentifier()]);
498 $this->
writeLog(4, 1, 121,
'Target was not within your mountpoints! T="%s"', [$fileObject->getIdentifier()]);
501 $this->
writeLog(4, 1, 120,
'Could not delete directory "%s"! Write-permission problem?', [$fileObject->getIdentifier()]);
527 foreach ($files as $file) {
528 $fileUids[] = $file->
getUid();
531 $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable(
'sys_refindex');
532 $queryBuilder->getRestrictions()->removeAll()->add(GeneralUtility::makeInstance(DeletedRestriction::class));
533 $numberOfReferences = $queryBuilder
535 ->from(
'sys_refindex')
537 $queryBuilder->expr()->eq(
539 $queryBuilder->createNamedParameter(
'sys_file', \PDO::PARAM_STR)
541 $queryBuilder->expr()->in(
543 $queryBuilder->createNamedParameter($fileUids, Connection::PARAM_INT_ARRAY)
545 $queryBuilder->expr()->neq(
547 $queryBuilder->createNamedParameter(
'sys_file_metadata', \PDO::PARAM_STR)
549 $queryBuilder->expr()->eq(
551 $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)
553 )->execute()->fetchColumn(0);
555 $hasReferences = $numberOfReferences > 0;
556 if ($hasReferences) {
558 $flashMessage = GeneralUtility::makeInstance(
560 $this->
getLanguageService()->sL(
'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:message.description.folderNotDeletedHasFilesWithReferences'),
561 $this->
getLanguageService()->sL(
'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:message.header.folderNotDeletedHasFilesWithReferences'),
568 return $hasReferences;
580 $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable(
'sys_refindex');
581 $queryBuilder->getRestrictions()->removeAll();
582 $fileReference = $queryBuilder
583 ->select(
'uid_foreign',
'tablenames',
'fieldname',
'sorting_foreign')
584 ->from(
'sys_file_reference')
586 $queryBuilder->expr()->eq(
588 $queryBuilder->createNamedParameter($referenceRecord[
'recuid'], \PDO::PARAM_INT)
595 'recuid' => $fileReference[
'uid_foreign'],
596 'tablename' => $fileReference[
'tablenames'],
597 'field' => $fileReference[
'fieldname'],
600 'sorting' => $fileReference[
'sorting_foreign']
614 $object = $this->fileFactory->retrieveFileOrFolderObject($identifier);
615 if (!is_object($object)) {
616 throw new \TYPO3\CMS\Core\Resource\Exception\InvalidFileException(
'The item ' . $identifier .
' was not a file or directory!!', 1320122453);
618 if ($object->getStorage()->getUid() === 0) {
619 throw new \TYPO3\CMS\Core\Resource\Exception\InsufficientFileAccessPermissionsException(
'You are not allowed to access files outside your storages', 1375889830);
643 if (!$targetFolderObject instanceof Folder) {
644 $this->
writeLog(2, 2, 100,
'Destination "%s" was not a directory', [$cmds[
'target']]);
649 $appendSuffixOnConflict = (string)$cmds[
'altName'];
650 $resultObject =
null;
653 if ($sourceFileObject instanceof File) {
655 $resultObject = $sourceFileObject->copyTo($targetFolderObject,
null, $conflictMode);
656 }
catch (InsufficientUserPermissionsException $e) {
657 $this->
writeLog(2, 1, 114,
'You are not allowed to copy files', []);
659 }
catch (\
TYPO3\CMS\Core\Resource\Exception\InsufficientFileAccessPermissionsException $e) {
660 $this->
writeLog(2, 1, 110,
'Could not access all necessary resources. Source file or destination maybe was not within your mountpoints? T="%s", D="%s"', [$sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
661 $this->
addMessageToFlashMessageQueue(
'FileUtility.CouldNotAccessAllNecessaryResources', [$sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
662 }
catch (IllegalFileExtensionException $e) {
663 $this->
writeLog(2, 1, 111,
'Extension of file name "%s" is not allowed in "%s"!', [$sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
664 $this->
addMessageToFlashMessageQueue(
'FileUtility.ExtensionOfFileNameIsNotAllowedIn', [$sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
665 }
catch (ExistingTargetFileNameException $e) {
666 $this->
writeLog(2, 1, 112,
'File "%s" already exists in folder "%s"!', [$sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
667 $this->
addMessageToFlashMessageQueue(
'FileUtility.FileAlreadyExistsInFolder', [$sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
668 }
catch (NotImplementedMethodException $e) {
669 $this->
writeLog(3, 1, 128,
'The function to copy a file between storages is not yet implemented', []);
671 }
catch (\RuntimeException $e) {
672 $this->
writeLog(2, 2, 109,
'File "%s" WAS NOT copied to "%s"! Write-permission problem?', [$sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
673 $this->
addMessageToFlashMessageQueue(
'FileUtility.FileWasNotCopiedTo', [$sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
676 $this->
writeLog(2, 0, 1,
'File "%s" copied to "%s"', [$sourceFileObject->getIdentifier(), $resultObject->getIdentifier()]);
681 $sourceFolderObject = $sourceFileObject;
683 $resultObject = $sourceFolderObject->copyTo($targetFolderObject,
null, $conflictMode);
684 }
catch (InsufficientUserPermissionsException $e) {
685 $this->
writeLog(2, 1, 125,
'You are not allowed to copy directories', []);
687 }
catch (\
TYPO3\CMS\Core\Resource\Exception\InsufficientFileAccessPermissionsException $e) {
688 $this->
writeLog(2, 1, 110,
'Could not access all necessary resources. Source file or destination maybe was not within your mountpoints? T="%s", D="%s"', [$sourceFolderObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
689 $this->
addMessageToFlashMessageQueue(
'FileUtility.CouldNotAccessAllNecessaryResources', [$sourceFolderObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
690 }
catch (InsufficientFolderAccessPermissionsException $e) {
691 $this->
writeLog(2, 1, 121,
'You don\'t have full access to the destination directory "%s"!', [$targetFolderObject->getIdentifier()]);
693 }
catch (\
TYPO3\CMS\Core\Resource\Exception\InvalidTargetFolderException $e) {
694 $this->
writeLog(2, 1, 122,
'Cannot copy folder "%s" into target folder "%s", because the target folder is already within the folder to be copied!', [$sourceFolderObject->getName(), $targetFolderObject->getName()]);
695 $this->
addMessageToFlashMessageQueue(
'FileUtility.CannotCopyFolderIntoTargetFolderBecauseTheTargetFolderIsAlreadyWithinTheFolderToBeCopied', [$sourceFolderObject->getName(), $targetFolderObject->getName()]);
696 }
catch (ExistingTargetFolderException $e) {
697 $this->
writeLog(2, 1, 123,
'Target "%s" already exists!', [$targetFolderObject->getIdentifier()]);
699 }
catch (NotImplementedMethodException $e) {
700 $this->
writeLog(3, 1, 129,
'The function to copy a folder between storages is not yet implemented', []);
702 }
catch (\RuntimeException $e) {
703 $this->
writeLog(2, 2, 119,
'Directory "%s" WAS NOT copied to "%s"! Write-permission problem?', [$sourceFolderObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
704 $this->
addMessageToFlashMessageQueue(
'FileUtility.DirectoryWasNotCopiedTo', [$sourceFolderObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
707 $this->
writeLog(2, 0, 2,
'Directory "%s" copied to "%s"', [$sourceFolderObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
711 return $resultObject;
732 if (!$targetFolderObject instanceof Folder) {
733 $this->
writeLog(3, 2, 100,
'Destination "%s" was not a directory', [$cmds[
'target']]);
737 $alternativeName = (string)$cmds[
'altName'];
738 $resultObject =
null;
740 if ($sourceFileObject instanceof File) {
742 if ($alternativeName !==
'') {
749 $this->
writeLog(3, 0, 1,
'File "%s" moved to "%s"', [$sourceFileObject->getIdentifier(), $resultObject->getIdentifier()]);
751 }
catch (InsufficientUserPermissionsException $e) {
752 $this->
writeLog(3, 1, 114,
'You are not allowed to move files', []);
754 }
catch (\
TYPO3\CMS\Core\Resource\Exception\InsufficientFileAccessPermissionsException $e) {
755 $this->
writeLog(3, 1, 110,
'Could not access all necessary resources. Source file or destination maybe was not within your mountpoints? T="%s", D="%s"', [$sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
756 $this->
addMessageToFlashMessageQueue(
'FileUtility.CouldNotAccessAllNecessaryResources', [$sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
757 }
catch (IllegalFileExtensionException $e) {
758 $this->
writeLog(3, 1, 111,
'Extension of file name "%s" is not allowed in "%s"!', [$sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
759 $this->
addMessageToFlashMessageQueue(
'FileUtility.ExtensionOfFileNameIsNotAllowedIn', [$sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
760 }
catch (ExistingTargetFileNameException $e) {
761 $this->
writeLog(3, 1, 112,
'File "%s" already exists in folder "%s"!', [$sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
762 $this->
addMessageToFlashMessageQueue(
'FileUtility.FileAlreadyExistsInFolder', [$sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
763 }
catch (NotImplementedMethodException $e) {
764 $this->
writeLog(3, 1, 126,
'The function to move a file between storages is not yet implemented', []);
766 }
catch (\RuntimeException $e) {
767 $this->
writeLog(3, 2, 109,
'File "%s" WAS NOT copied to "%s"! Write-permission problem?', [$sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
768 $this->
addMessageToFlashMessageQueue(
'FileUtility.FileWasNotCopiedTo', [$sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
772 $sourceFolderObject = $sourceFileObject;
774 if ($alternativeName !==
'') {
781 $this->
writeLog(3, 0, 2,
'Directory "%s" moved to "%s"', [$sourceFolderObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
783 }
catch (InsufficientUserPermissionsException $e) {
784 $this->
writeLog(3, 1, 125,
'You are not allowed to move directories', []);
786 }
catch (\
TYPO3\CMS\Core\Resource\Exception\InsufficientFileAccessPermissionsException $e) {
787 $this->
writeLog(3, 1, 110,
'Could not access all necessary resources. Source file or destination maybe was not within your mountpoints? T="%s", D="%s"', [$sourceFolderObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
788 $this->
addMessageToFlashMessageQueue(
'FileUtility.CouldNotAccessAllNecessaryResources', [$sourceFolderObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
789 }
catch (InsufficientFolderAccessPermissionsException $e) {
790 $this->
writeLog(3, 1, 121,
'You don\'t have full access to the destination directory "%s"!', [$targetFolderObject->getIdentifier()]);
792 }
catch (\
TYPO3\CMS\Core\Resource\Exception\InvalidTargetFolderException $e) {
793 $this->
writeLog(3, 1, 122,
'Cannot move folder "%s" into target folder "%s", because the target folder is already within the folder to be moved!', [$sourceFolderObject->getName(), $targetFolderObject->getName()]);
794 $this->
addMessageToFlashMessageQueue(
'FileUtility.CannotMoveFolderIntoTargetFolderBecauseTheTargetFolderIsAlreadyWithinTheFolderToBeMoved', [$sourceFolderObject->getName(), $targetFolderObject->getName()]);
795 }
catch (ExistingTargetFolderException $e) {
796 $this->
writeLog(3, 1, 123,
'Target "%s" already exists!', [$targetFolderObject->getIdentifier()]);
798 }
catch (NotImplementedMethodException $e) {
799 $this->
writeLog(3, 1, 127,
'The function to move a folder between storages is not yet implemented', []);
801 }
catch (\RuntimeException $e) {
802 $this->
writeLog(3, 2, 119,
'Directory "%s" WAS NOT moved to "%s"! Write-permission problem?', [$sourceFolderObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
803 $this->
addMessageToFlashMessageQueue(
'FileUtility.DirectoryWasNotMovedTo', [$sourceFolderObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
806 return $resultObject;
823 $sourceFile = $sourceFileObject->getName();
824 $targetFile = $cmds[
'target'];
825 $resultObject =
null;
826 if ($sourceFileObject instanceof File) {
829 $resultObject = $sourceFileObject->rename($targetFile, $this->existingFilesConflictMode);
830 if ($resultObject->getName() !== $targetFile) {
831 $this->
writeLog(5, 1, 1,
'File renamed from "%s" to "%s". Filename had to be sanitized!', [$sourceFile, $targetFile]);
834 $this->
writeLog(5, 0, 1,
'File renamed from "%s" to "%s"', [$sourceFile, $targetFile]);
836 if ($sourceFile === $resultObject->getName()) {
841 }
catch (InsufficientUserPermissionsException $e) {
842 $this->
writeLog(5, 1, 102,
'You are not allowed to rename files!', []);
844 }
catch (IllegalFileExtensionException $e) {
845 $this->
writeLog(5, 1, 101,
'Extension of file name "%s" or "%s" was not allowed!', [$sourceFileObject->getName(), $targetFile]);
847 }
catch (ExistingTargetFileNameException $e) {
848 $this->
writeLog(5, 1, 120,
'Destination "%s" existed already!', [$targetFile]);
850 }
catch (NotInMountPointException $e) {
851 $this->
writeLog(5, 1, 121,
'Destination path "%s" was not within your mountpoints!', [$targetFile]);
853 }
catch (\RuntimeException $e) {
854 $this->
writeLog(5, 1, 100,
'File "%s" was not renamed! Write-permission problem in "%s"?', [$sourceFileObject->getName(), $targetFile]);
861 $resultObject = $sourceFileObject->rename($targetFile);
862 $newFolderName = $resultObject->getName();
863 $this->
writeLog(5, 0, 2,
'Directory renamed from "%s" to "%s"', [$sourceFile, $targetFile]);
864 if ($sourceFile === $newFolderName) {
867 if ($newFolderName === $targetFile) {
873 }
catch (InsufficientUserPermissionsException $e) {
874 $this->
writeLog(5, 1, 111,
'You are not allowed to rename directories!', []);
876 }
catch (ExistingTargetFileNameException $e) {
877 $this->
writeLog(5, 1, 120,
'Destination "%s" existed already!', [$targetFile]);
879 }
catch (NotInMountPointException $e) {
880 $this->
writeLog(5, 1, 121,
'Destination path "%s" was not within your mountpoints!', [$targetFile]);
882 }
catch (\RuntimeException $e) {
883 $this->
writeLog(5, 1, 110,
'Directory "%s" was not renamed! Write-permission problem in "%s"?', [$sourceFileObject->getName(), $targetFile]);
887 return $resultObject;
903 if (!$targetFolderObject instanceof Folder) {
904 $this->
writeLog(6, 2, 104,
'Destination "%s" was not a directory', [$cmds[
'target']]);
908 $folderName = $cmds[
'data'];
910 $resultObject = $targetFolderObject->createFolder($folderName);
911 $this->
writeLog(6, 0, 1,
'Directory "%s" created in "%s"', [$folderName, $targetFolderObject->getIdentifier()]);
913 }
catch (\
TYPO3\CMS\Core\Resource\Exception\InvalidFileNameException $e) {
914 $this->
writeLog(6, 1, 104,
'Invalid folder name "%s"!', [$folderName]);
916 }
catch (\
TYPO3\CMS\Core\Resource\Exception\InsufficientFolderWritePermissionsException $e) {
917 $this->
writeLog(6, 1, 103,
'You are not allowed to create directories!', []);
919 }
catch (\
TYPO3\CMS\Core\Resource\Exception\NotInMountPointException $e) {
920 $this->
writeLog(6, 1, 102,
'Destination path "%s" was not within your mountpoints!', [$targetFolderObject->getIdentifier()]);
922 }
catch (\
TYPO3\CMS\Core\Resource\Exception\ExistingTargetFolderException $e) {
923 $this->
writeLog(6, 1, 101,
'File or directory "%s" existed already!', [$folderName]);
925 }
catch (\RuntimeException $e) {
926 $this->
writeLog(6, 1, 100,
'Directory "%s" not created. Write-permission problem in "%s"?', [$folderName, $targetFolderObject->getIdentifier()]);
929 return $resultObject;
944 if (!$targetFolderObject instanceof Folder) {
945 $this->
writeLog(8, 2, 104,
'Destination "%s" was not a directory', [$cmds[
'target']]);
949 $resultObject =
null;
950 $fileName = $cmds[
'data'];
952 $resultObject = $targetFolderObject->createFile($fileName);
953 $this->
writeLog(8, 0, 1,
'File created: "%s"', [$fileName]);
954 if ($resultObject->getName() !== $fileName) {
958 }
catch (IllegalFileExtensionException $e) {
959 $this->
writeLog(8, 1, 106,
'Extension of file "%s" was not allowed!', [$fileName]);
961 }
catch (InsufficientFolderWritePermissionsException $e) {
962 $this->
writeLog(8, 1, 103,
'You are not allowed to create files!', []);
964 }
catch (NotInMountPointException $e) {
965 $this->
writeLog(8, 1, 102,
'Destination path "%s" was not within your mountpoints!', [$targetFolderObject->getIdentifier()]);
967 }
catch (ExistingTargetFileNameException $e) {
968 $this->
writeLog(8, 1, 101,
'File existed already in "%s"!', [$targetFolderObject->getIdentifier()]);
970 }
catch (InvalidFileNameException $e) {
971 $this->
writeLog(8, 1, 106,
'File name "%s" was not allowed!', [$fileName]);
973 }
catch (\RuntimeException $e) {
974 $this->
writeLog(8, 1, 100,
'File "%s" was not created! Write-permission problem in "%s"?', [$fileName, $targetFolderObject->getIdentifier()]);
977 return $resultObject;
990 $fileIdentifier = $cmds[
'target'];
993 $content = $cmds[
'data'];
994 if (!$fileObject instanceof
File) {
995 $this->
writeLog(9, 2, 123,
'Target "%s" was not a file!', [$fileIdentifier]);
999 $extList =
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'textfile_ext'];
1000 if (!GeneralUtility::inList($extList, $fileObject->getExtension())) {
1001 $this->
writeLog(9, 1, 102,
'File extension "%s" is not a textfile format! (%s)', [$fileObject->getExtension(), $extList]);
1006 $fileObject->setContents($content);
1008 $this->
writeLog(9, 0, 1,
'File saved to "%s", bytes: %s, MD5: %s ', [$fileObject->getIdentifier(), $fileObject->getSize(), md5($content)]);
1012 $this->
writeLog(9, 1, 104,
'You are not allowed to edit files!', []);
1016 $this->
writeLog(9, 1, 100,
'File "%s" was not saved! Write-permission problem?', [$fileObject->getIdentifier()]);
1020 $this->
writeLog(9, 1, 100,
'File "%s" was not saved! File extension rejected!', [$fileObject->getIdentifier()]);
1023 }
catch (\RuntimeException $e) {
1024 $this->
writeLog(9, 1, 100,
'File "%s" was not saved! File extension rejected!', [$fileObject->getIdentifier()]);
1062 $uploadPosition = $cmds[
'data'];
1063 $uploadedFileData = $_FILES[
'upload_' . $uploadPosition];
1064 if (empty($uploadedFileData[
'name']) || is_array($uploadedFileData[
'name']) && empty($uploadedFileData[
'name'][0])) {
1065 $this->
writeLog(1, 2, 108,
'No file was uploaded!', []);
1072 if (!is_array($uploadedFileData[
'name'])) {
1073 $uploadedFileData = [
1074 'name' => [$uploadedFileData[
'name']],
1075 'type' => [$uploadedFileData[
'type']],
1076 'tmp_name' => [$uploadedFileData[
'tmp_name']],
1077 'size' => [$uploadedFileData[
'size']]
1080 $resultObjects = [];
1081 $numberOfUploadedFilesForPosition = count($uploadedFileData[
'name']);
1083 for ($i = 0; $i < $numberOfUploadedFilesForPosition; $i++) {
1085 'name' => $uploadedFileData[
'name'][$i],
1086 'type' => $uploadedFileData[
'type'][$i],
1087 'tmp_name' => $uploadedFileData[
'tmp_name'][$i],
1088 'size' => $uploadedFileData[
'size'][$i]
1092 $fileObject = $targetFolderObject->addUploadedFile($fileInfo, (
string)$this->existingFilesConflictMode);
1095 $this->
getIndexer($fileObject->getStorage())->updateIndexEntry($fileObject);
1097 $resultObjects[] = $fileObject;
1098 $this->internalUploadMap[$uploadPosition] = $fileObject->getCombinedIdentifier();
1099 if ($fileObject->getName() !== $fileInfo[
'name']) {
1102 $this->
writeLog(1, 0, 1,
'Uploading file "%s" to "%s"', [$fileInfo[
'name'], $targetFolderObject->getIdentifier()]);
1104 }
catch (InsufficientFileWritePermissionsException $e) {
1105 $this->
writeLog(1, 1, 107,
'You are not allowed to override "%s"!', [$fileInfo[
'name']]);
1107 }
catch (UploadException $e) {
1108 $this->
writeLog(1, 2, 106,
'The upload has failed, no uploaded file found!', []);
1110 }
catch (InsufficientUserPermissionsException $e) {
1111 $this->
writeLog(1, 1, 105,
'You are not allowed to upload files!', []);
1113 }
catch (UploadSizeException $e) {
1114 $this->
writeLog(1, 1, 104,
'The uploaded file "%s" exceeds the size-limit', [$fileInfo[
'name']]);
1116 }
catch (InsufficientFolderWritePermissionsException $e) {
1117 $this->
writeLog(1, 1, 103,
'Destination path "%s" was not within your mountpoints!', [$targetFolderObject->getIdentifier()]);
1119 }
catch (IllegalFileExtensionException $e) {
1120 $this->
writeLog(1, 1, 102,
'Extension of file name "%s" is not allowed in "%s"!', [$fileInfo[
'name'], $targetFolderObject->getIdentifier()]);
1121 $this->
addMessageToFlashMessageQueue(
'FileUtility.ExtensionOfFileNameIsNotAllowedIn', [$fileInfo[
'name'], $targetFolderObject->getIdentifier()]);
1122 }
catch (ExistingTargetFileNameException $e) {
1123 $this->
writeLog(1, 1, 101,
'No unique filename available in "%s"!', [$targetFolderObject->getIdentifier()]);
1125 }
catch (\RuntimeException $e) {
1126 $this->
writeLog(1, 1, 100,
'Uploaded file could not be moved! Write-permission problem in "%s"?', [$targetFolderObject->getIdentifier()]);
1131 return $resultObjects;
1146 $uploadPosition = $cmdArr[
'data'];
1147 $fileInfo = $_FILES[
'replace_' . $uploadPosition];
1148 if (empty($fileInfo[
'name'])) {
1149 $this->
writeLog(1, 2, 108,
'No file was uploaded for replacing!', []);
1154 $keepFileName = ($cmdArr[
'keepFilename'] == 1) ?
true :
false;
1155 $resultObjects = [];
1160 $resourceStorage = $fileObjectToReplace->
getStorage();
1167 if ($keepFileName ===
false) {
1173 $resultObjects[] = $fileObject;
1174 $this->internalUploadMap[$uploadPosition] = $fileObject->getCombinedIdentifier();
1176 $this->
writeLog(1, 0, 1,
'Replacing file "%s" to "%s"', [$fileInfo[
'name'], $fileObjectToReplace->getIdentifier()]);
1178 }
catch (InsufficientFileWritePermissionsException $e) {
1179 $this->
writeLog(1, 1, 107,
'You are not allowed to override "%s"!', [$fileInfo[
'name']]);
1181 }
catch (UploadException $e) {
1182 $this->
writeLog(1, 2, 106,
'The upload has failed, no uploaded file found!', []);
1184 }
catch (InsufficientUserPermissionsException $e) {
1185 $this->
writeLog(1, 1, 105,
'You are not allowed to upload files!', []);
1187 }
catch (UploadSizeException $e) {
1188 $this->
writeLog(1, 1, 104,
'The uploaded file "%s" exceeds the size-limit', [$fileInfo[
'name']]);
1190 }
catch (InsufficientFolderWritePermissionsException $e) {
1191 $this->
writeLog(1, 1, 103,
'Destination path "%s" was not within your mountpoints!', [$fileObjectToReplace->getIdentifier()]);
1193 }
catch (IllegalFileExtensionException $e) {
1194 $this->
writeLog(1, 1, 102,
'Extension of file name "%s" is not allowed in "%s"!', [$fileInfo[
'name'], $fileObjectToReplace->getIdentifier()]);
1195 $this->
addMessageToFlashMessageQueue(
'FileUtility.ExtensionOfFileNameIsNotAllowedIn', [$fileInfo[
'name'], $fileObjectToReplace->getIdentifier()]);
1196 }
catch (ExistingTargetFileNameException $e) {
1197 $this->
writeLog(1, 1, 101,
'No unique filename available in "%s"!', [$fileObjectToReplace->getIdentifier()]);
1199 }
catch (\RuntimeException $e) {
1202 return $resultObjects;
1213 $flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class);
1216 $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
1217 $defaultFlashMessageQueue->enqueue($flashMessage);
1228 return GeneralUtility::makeInstance(\
TYPO3\CMS\Core\Resource\Index\Indexer::class, $storage);