2 namespace TYPO3\CMS\Core\Utility\File;
24 use TYPO3\CMS\Core\Resource\Exception\ResourceDoesNotExistException;
31 use TYPO3\CMS\Core\Type\Exception\InvalidEnumerationValueException;
100 'renameFile' =>
false,
101 'unzipFile' =>
false,
102 'deleteFile' =>
false,
104 'addFolder' =>
false,
105 'readFolder' =>
false,
106 'writeFolder' =>
false,
107 'copyFolder' =>
false,
108 'moveFolder' =>
false,
109 'renameFolder' =>
false,
110 'deleteFolder' =>
false,
111 'recursivedeleteFolder' =>
false
176 'Invalid argument, received: "%s", expected a value from enumeration \TYPO3\CMS\Core\Resource\DuplicationBehavior (%s)',
201 $this->fileCmdMap = $fileCmds;
213 if (empty($permissions)) {
214 $permissions =
$GLOBALS[
'BE_USER']->getFilePermissions();
216 $this->actionPerms = $permissions;
228 if (!$this->isInit) {
231 if (is_array($this->fileCmdMap)) {
233 if ($this->fileCmdMap[
'upload']) {
234 $uploads = $this->fileCmdMap[
'upload'];
235 foreach ($uploads as $upload) {
236 if (empty($_FILES[(
'upload_' . $upload[
'data'])][
'name'])
237 || (is_array($_FILES[(
'upload_' . $upload[
'data'])][
'name'])
238 && empty($_FILES[(
'upload_' . $upload[
'data'])][
'name'][0])
241 unset($this->fileCmdMap[
'upload'][$upload[
'data']]);
244 if (empty($this->fileCmdMap[
'upload'])) {
245 $this->writelog(1, 1, 108,
'No file was uploaded!',
'');
250 if ($this->fileCmdMap[
'newfolder']) {
251 foreach ($this->fileCmdMap[
'newfolder'] as $key => $cmdArr) {
252 if (empty($cmdArr[
'data'])) {
253 unset($this->fileCmdMap[
'newfolder'][$key]);
256 if (empty($this->fileCmdMap[
'newfolder'])) {
257 $this->
writeLog(6, 1, 108,
'No name for new folder given!',
'');
262 foreach ($this->fileCmdMap as $action => $actionData) {
264 if (is_array($actionData)) {
265 $result[$action] = array();
266 foreach ($actionData as $cmdArr) {
272 $result[$action][] = $this->func_delete($cmdArr);
275 $result[$action][] = $this->func_copy($cmdArr);
278 $result[$action][] = $this->
func_move($cmdArr);
290 $result[$action][] = $this->
func_edit($cmdArr);
293 $result[$action][] = $this->func_upload($cmdArr);
299 $result[$action][] = $this->
func_unzip($cmdArr);
303 if (is_array(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_extfilefunc.php'][
'processData'])) {
304 foreach (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_extfilefunc.php'][
'processData'] as $classRef) {
307 throw new \UnexpectedValueException(
'$hookObject must implement interface TYPO3\\CMS\\Core\\Utility\\File\\ExtendedFileUtilityProcessDataHookInterface', 1279719168);
309 $hookObject->processData_postProcessAction($action, $cmdArr, $result[$action], $this);
334 $this->addFlashMessage($flashMessage);
356 public function writeLog($action, $error, $details_nr, $details, $data)
361 $this->
getBackendUser()->writelog($type, $action, $error, $details_nr, $details, $data);
364 $this->lastError = vsprintf($details, $data);
380 public function func_delete(array $cmds)
383 if (!$this->isInit) {
390 }
catch (ResourceDoesNotExistException $e) {
393 sprintf(
$GLOBALS[
'LANG']->sL(
'LLL:EXT:lang/locallang_core.xlf:message.description.fileNotFound'), $cmds[
'data']),
394 $GLOBALS[
'LANG']->sL(
'LLL:EXT:lang/locallang_core.xlf:message.header.fileNotFound'),
398 $this->addFlashMessage($flashMessage);
404 if ($fileObject instanceof File) {
408 $table =
'sys_refindex';
409 $refIndexRecords = $databaseConnection->exec_SELECTgetRows(
412 'deleted=0 AND ref_table=' . $databaseConnection->fullQuoteStr(
'sys_file', $table)
413 .
' AND ref_uid=' . (int)$fileObject->getUid()
414 .
' AND tablename != ' . $databaseConnection->fullQuoteStr(
'sys_file_metadata', $table)
417 if (!empty($refIndexRecords)) {
418 $shortcutContent = array();
419 $brokenReferences = array();
421 foreach ($refIndexRecords as $fileReferenceRow) {
422 if ($fileReferenceRow[
'tablename'] ===
'sys_file_reference') {
426 if ($shortcutRecord) {
427 $shortcutContent[] =
'[record:' . $row[
'tablename'] .
':' . $row[
'recuid'] .
']';
429 $brokenReferences[] = $fileReferenceRow[
'ref_uid'];
433 if (!empty($brokenReferences)) {
437 sprintf(
$GLOBALS[
'LANG']->sL(
'LLL:EXT:lang/locallang_core.xlf:message.description.fileHasBrokenReferences'), count($brokenReferences)),
438 $GLOBALS[
'LANG']->sL(
'LLL:EXT:lang/locallang_core.xlf:message.header.fileHasBrokenReferences'),
442 $this->addFlashMessage($flashMessage);
444 if (!empty($shortcutContent)) {
448 sprintf(
$GLOBALS[
'LANG']->sL(
'LLL:EXT:lang/locallang_core.xlf:message.description.fileNotDeletedHasReferences'), $fileObject->getName()) .
' ' . implode(
', ', $shortcutContent),
449 $GLOBALS[
'LANG']->sL(
'LLL:EXT:lang/locallang_core.xlf:message.header.fileNotDeletedHasReferences'),
453 $this->addFlashMessage($flashMessage);
460 $result = $fileObject->delete();
465 sprintf(
$GLOBALS[
'LANG']->sL(
'LLL:EXT:lang/locallang_core.xlf:message.description.fileDeleted'), $fileObject->getName()),
466 $GLOBALS[
'LANG']->sL(
'LLL:EXT:lang/locallang_core.xlf:message.header.fileDeleted'),
470 $this->addFlashMessage($flashMessage);
472 $this->writelog(4, 0, 1,
'File "%s" deleted', array($fileObject->getIdentifier()));
473 }
catch (\TYPO3\CMS\Core\Resource\Exception\InsufficientFileAccessPermissionsException $e) {
474 $this->writelog(4, 1, 112,
'You are not allowed to access the file', array($fileObject->getIdentifier()));
475 }
catch (\TYPO3\CMS\Core\Resource\Exception\NotInMountPointException $e) {
476 $this->writelog(4, 1, 111,
'Target was not within your mountpoints! T="%s"', array($fileObject->getIdentifier()));
477 }
catch (\RuntimeException $e) {
478 $this->writelog(4, 1, 110,
'Could not delete file "%s". Write-permission problem?', array($fileObject->getIdentifier()));
483 if (!$this->folderHasFilesInUse($fileObject)) {
485 $result = $fileObject->delete(
true);
491 sprintf(
$GLOBALS[
'LANG']->sL(
'LLL:EXT:lang/locallang_core.xlf:message.description.folderDeleted'), $fileObject->getName()),
492 $GLOBALS[
'LANG']->sL(
'LLL:EXT:lang/locallang_core.xlf:message.header.folderDeleted'),
496 $this->addFlashMessage($flashMessage);
498 $this->writelog(4, 0, 3,
'Directory "%s" deleted', array($fileObject->getIdentifier()));
500 }
catch (\TYPO3\CMS\Core\Resource\Exception\InsufficientUserPermissionsException $e) {
501 $this->writelog(4, 1, 120,
'Could not delete directory! Is directory "%s" empty? (You are not allowed to delete directories recursively).', array($fileObject->getIdentifier()));
502 }
catch (\TYPO3\CMS\Core\Resource\Exception\InsufficientFolderAccessPermissionsException $e) {
503 $this->writelog(4, 1, 123,
'You are not allowed to access the directory', array($fileObject->getIdentifier()));
504 }
catch (\TYPO3\CMS\Core\Resource\Exception\NotInMountPointException $e) {
505 $this->writelog(4, 1, 121,
'Target was not within your mountpoints! T="%s"', array($fileObject->getIdentifier()));
506 }
catch (\TYPO3\CMS\Core\Resource\Exception\FileOperationErrorException $e) {
507 $this->writelog(4, 1, 120,
'Could not delete directory "%s"! Write-permission problem?', array($fileObject->getIdentifier()));
523 public function folderHasFilesInUse(Folder $folder)
532 foreach ($files as $file) {
533 $fileUids[] = $file->getUid();
538 'deleted=0 AND ref_table="sys_file" AND ref_uid IN (' . implode(
',', $fileUids) .
') AND tablename<>"sys_file_metadata"'
541 $hasReferences = $numberOfReferences > 0;
542 if ($hasReferences) {
546 $GLOBALS[
'LANG']->sL(
'LLL:EXT:lang/locallang_core.xlf:message.description.folderNotDeletedHasFilesWithReferences'),
547 $GLOBALS[
'LANG']->sL(
'LLL:EXT:lang/locallang_core.xlf:message.header.folderNotDeletedHasFilesWithReferences'),
551 $this->addFlashMessage($flashMessage);
554 return $hasReferences;
568 'sys_file_reference',
569 'uid=' . (
int)$referenceRecord[
'recuid']
572 'recuid' => $fileReference[
'uid_foreign'],
573 'tablename' => $fileReference[
'tablenames'],
574 'field' => $fileReference[
'fieldname'],
577 'sorting' => $fileReference[
'sorting_foreign']
590 $object = $this->fileFactory->retrieveFileOrFolderObject($identifier);
591 if (!is_object($object)) {
592 throw new \TYPO3\CMS\Core\Resource\Exception\InvalidFileException(
'The item ' . $identifier .
' was not a file or directory!!', 1320122453);
594 if ($object->getStorage()->getUid() === 0) {
595 throw new \TYPO3\CMS\Core\Resource\Exception\InsufficientFileAccessPermissionsException(
'You are not allowed to access files outside your storages', 1375889830);
613 protected function func_copy($cmds)
615 if (!$this->isInit) {
622 if (!$targetFolderObject instanceof Folder) {
623 $this->writelog(2, 2, 100,
'Destination "%s" was not a directory', array($cmds[
'target']));
627 $appendSuffixOnConflict = (string)$cmds[
'altName'];
628 $resultObject = null;
631 if ($sourceFileObject instanceof File) {
633 $resultObject = $sourceFileObject->copyTo($targetFolderObject, null, $conflictMode);
634 }
catch (\TYPO3\CMS\Core\Resource\Exception\InsufficientUserPermissionsException $e) {
635 $this->writelog(2, 1, 114,
'You are not allowed to copy files',
'');
636 }
catch (\TYPO3\CMS\Core\Resource\Exception\InsufficientFileAccessPermissionsException $e) {
637 $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"', array($sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()));
638 }
catch (\TYPO3\CMS\Core\Resource\Exception\IllegalFileExtensionException $e) {
639 $this->writelog(2, 1, 111,
'Extension of file name "%s" is not allowed in "%s"!', array($sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()));
640 }
catch (\TYPO3\CMS\Core\Resource\Exception\ExistingTargetFileNameException $e) {
641 $this->writelog(2, 1, 112,
'File "%s" already exists in folder "%s"!', array($sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()));
642 }
catch (\BadMethodCallException $e) {
643 $this->writelog(3, 1, 128,
'The function to copy a file between storages is not yet implemented', array());
644 }
catch (\RuntimeException $e) {
645 $this->writelog(2, 2, 109,
'File "%s" WAS NOT copied to "%s"! Write-permission problem?', array($sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()));
648 $this->writelog(2, 0, 1,
'File "%s" copied to "%s"', array($sourceFileObject->getIdentifier(), $resultObject->getIdentifier()));
652 $sourceFolderObject = $sourceFileObject;
654 $resultObject = $sourceFolderObject->copyTo($targetFolderObject, null, $conflictMode);
655 }
catch (\TYPO3\CMS\Core\Resource\Exception\InsufficientUserPermissionsException $e) {
656 $this->writelog(2, 1, 125,
'You are not allowed to copy directories',
'');
657 }
catch (\TYPO3\CMS\Core\Resource\Exception\InsufficientFileAccessPermissionsException $e) {
658 $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"', array($sourceFolderObject->getIdentifier(), $targetFolderObject->getIdentifier()));
659 }
catch (\TYPO3\CMS\Core\Resource\Exception\InsufficientFolderAccessPermissionsException $e) {
660 $this->writelog(2, 1, 121,
'You don\'t have full access to the destination directory "%s"!', array($targetFolderObject->getIdentifier()));
661 }
catch (\TYPO3\CMS\Core\Resource\Exception\InvalidTargetFolderException $e) {
662 $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!', array($sourceFolderObject->getName(), $targetFolderObject->getName()));
663 }
catch (\TYPO3\CMS\Core\Resource\Exception\ExistingTargetFolderException $e) {
664 $this->writelog(2, 1, 123,
'Target "%s" already exists!', array($targetFolderObject->getIdentifier()));
665 }
catch (\BadMethodCallException $e) {
666 $this->writelog(3, 1, 129,
'The function to copy a folder between storages is not yet implemented', array());
667 }
catch (\RuntimeException $e) {
668 $this->writelog(2, 2, 119,
'Directory "%s" WAS NOT copied to "%s"! Write-permission problem?', array($sourceFolderObject->getIdentifier(), $targetFolderObject->getIdentifier()));
671 $this->writelog(2, 0, 2,
'Directory "%s" copied to "%s"', array($sourceFolderObject->getIdentifier(), $targetFolderObject->getIdentifier()));
674 return $resultObject;
692 if (!$this->isInit) {
698 if (!$targetFolderObject instanceof Folder) {
699 $this->writelog(3, 2, 100,
'Destination "%s" was not a directory', array($cmds[
'target']));
702 $alternativeName = (string)$cmds[
'altName'];
703 $resultObject = null;
705 if ($sourceFileObject instanceof File) {
707 if ($alternativeName !==
'') {
714 $this->writelog(3, 0, 1,
'File "%s" moved to "%s"', array($sourceFileObject->getIdentifier(), $resultObject->getIdentifier()));
716 $this->writelog(3, 1, 114,
'You are not allowed to move files',
'');
718 $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"', array($sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()));
720 $this->writelog(3, 1, 111,
'Extension of file name "%s" is not allowed in "%s"!', array($sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()));
722 $this->writelog(3, 1, 112,
'File "%s" already exists in folder "%s"!', array($sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()));
723 }
catch (\BadMethodCallException $e) {
724 $this->writelog(3, 1, 126,
'The function to move a file between storages is not yet implemented', array());
725 }
catch (\RuntimeException $e) {
726 $this->writelog(3, 2, 109,
'File "%s" WAS NOT copied to "%s"! Write-permission problem?', array($sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()));
730 $sourceFolderObject = $sourceFileObject;
732 if ($alternativeName !==
'') {
739 $this->writelog(3, 0, 2,
'Directory "%s" moved to "%s"', array($sourceFolderObject->getIdentifier(), $targetFolderObject->getIdentifier()));
741 $this->writelog(3, 1, 125,
'You are not allowed to move directories',
'');
743 $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"', array($sourceFolderObject->getIdentifier(), $targetFolderObject->getIdentifier()));
745 $this->writelog(3, 1, 121,
'You don\'t have full access to the destination directory "%s"!', array($targetFolderObject->getIdentifier()));
747 $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!', array($sourceFolderObject->getName(), $targetFolderObject->getName()));
749 $this->writelog(3, 1, 123,
'Target "%s" already exists!', array($targetFolderObject->getIdentifier()));
750 }
catch (\BadMethodCallException $e) {
751 $this->writelog(3, 1, 127,
'The function to move a folder between storages is not yet implemented', array());
752 }
catch (\RuntimeException $e) {
753 $this->writelog(3, 2, 119,
'Directory "%s" WAS NOT moved to "%s"! Write-permission problem?', array($sourceFolderObject->getIdentifier(), $targetFolderObject->getIdentifier()));
756 return $resultObject;
772 if (!$this->isInit) {
776 $sourceFile = $sourceFileObject->getName();
777 $targetFile = $cmds[
'target'];
778 $resultObject = null;
779 if ($sourceFileObject instanceof File) {
782 $resultObject = $sourceFileObject->rename($targetFile);
783 $this->writelog(5, 0, 1,
'File renamed from "%s" to "%s"', array($sourceFile, $targetFile));
785 $this->writelog(5, 1, 102,
'You are not allowed to rename files!',
'');
787 $this->writelog(5, 1, 101,
'Extension of file name "%s" or "%s" was not allowed!', array($sourceFileObject->getName(), $targetFile));
789 $this->writelog(5, 1, 120,
'Destination "%s" existed already!', array($targetFile));
791 $this->writelog(5, 1, 121,
'Destination path "%s" was not within your mountpoints!', array($targetFile));
792 }
catch (\RuntimeException $e) {
793 $this->writelog(5, 1, 100,
'File "%s" was not renamed! Write-permission problem in "%s"?', array($sourceFileObject->getName(), $targetFile));
799 $resultObject = $sourceFileObject->rename($targetFile);
800 $this->writelog(5, 0, 2,
'Directory renamed from "%s" to "%s"', array($sourceFile, $targetFile));
802 $this->writelog(5, 1, 111,
'You are not allowed to rename directories!',
'');
804 $this->writelog(5, 1, 120,
'Destination "%s" existed already!', array($targetFile));
806 $this->writelog(5, 1, 121,
'Destination path "%s" was not within your mountpoints!', array($targetFile));
807 }
catch (\RuntimeException $e) {
808 $this->writelog(5, 1, 110,
'Directory "%s" was not renamed! Write-permission problem in "%s"?', array($sourceFileObject->getName(), $targetFile));
811 return $resultObject;
826 if (!$this->isInit) {
830 if (!$targetFolderObject instanceof Folder) {
831 $this->writelog(6, 2, 104,
'Destination "%s" was not a directory', array($cmds[
'target']));
834 $resultObject = null;
836 $folderName = $cmds[
'data'];
837 $resultObject = $targetFolderObject->createFolder($folderName);
838 $this->writelog(6, 0, 1,
'Directory "%s" created in "%s"', array($folderName, $targetFolderObject->getIdentifier() .
'/'));
840 $this->writelog(6, 1, 104,
'Invalid folder name "%s"!', [$folderName]);
842 $this->writelog(6, 1, 103,
'You are not allowed to create directories!',
'');
844 $this->writelog(6, 1, 102,
'Destination path "%s" was not within your mountpoints!', array($targetFolderObject->getIdentifier() .
'/'));
846 $this->writelog(6, 1, 101,
'File or directory "%s" existed already!', array($folderName));
847 }
catch (\RuntimeException $e) {
848 $this->writelog(6, 1, 100,
'Directory "%s" not created. Write-permission problem in "%s"?', array($folderName, $targetFolderObject->getIdentifier() .
'/'));
850 return $resultObject;
864 if (!$this->isInit) {
868 if (!$targetFolderObject instanceof Folder) {
869 $this->writelog(8, 2, 104,
'Destination "%s" was not a directory', array($cmds[
'target']));
872 $resultObject = null;
874 $fileName = $cmds[
'data'];
875 $resultObject = $targetFolderObject->createFile($fileName);
876 $this->writelog(8, 0, 1,
'File created: "%s"', array($fileName));
878 $this->
writeLog(8, 1, 106,
'Extension of file "%s" was not allowed!', array($fileName));
880 $this->writelog(8, 1, 103,
'You are not allowed to create files!',
'');
882 $this->writelog(8, 1, 102,
'Destination path "%s" was not within your mountpoints!', array($targetFolderObject->getIdentifier()));
884 $this->writelog(8, 1, 101,
'File existed already in "%s"!', array($targetFolderObject->getIdentifier()));
886 $this->writelog(8, 1, 106,
'File name "%s" was not allowed!', $fileName);
887 }
catch (\RuntimeException $e) {
888 $this->writelog(8, 1, 100,
'File "%s" was not created! Write-permission problem in "%s"?', array($fileName, $targetFolderObject->getIdentifier()));
890 return $resultObject;
901 if (!$this->isInit) {
906 $fileIdentifier = $cmds[
'target'];
909 $content = $cmds[
'data'];
910 if (!$fileObject instanceof File) {
911 $this->writelog(9, 2, 123,
'Target "%s" was not a file!', array($fileIdentifier));
914 $extList =
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'textfile_ext'];
916 $this->writelog(9, 1, 102,
'File extension "%s" is not a textfile format! (%s)', array($fileObject->getExtension(), $extList));
920 $fileObject->setContents($content);
922 $this->writelog(9, 0, 1,
'File saved to "%s", bytes: %s, MD5: %s ', array($fileObject->getIdentifier(), $fileObject->getSize(), md5($content)));
925 $this->writelog(9, 1, 104,
'You are not allowed to edit files!',
'');
928 $this->writelog(9, 1, 100,
'File "%s" was not saved! Write-permission problem?', array($fileObject->getIdentifier()));
931 $this->writelog(9, 1, 100,
'File "%s" was not saved! File extension rejected!', array($fileObject->getIdentifier()));
964 public function func_upload($cmds)
966 if (!$this->isInit) {
969 $uploadPosition = $cmds[
'data'];
970 $uploadedFileData = $_FILES[
'upload_' . $uploadPosition];
971 if (empty($uploadedFileData[
'name']) || is_array($uploadedFileData[
'name']) && empty($uploadedFileData[
'name'][0])) {
972 $this->writelog(1, 2, 108,
'No file was uploaded!',
'');
978 if (!is_array($uploadedFileData[
'name'])) {
979 $uploadedFileData = array(
980 'name' => array($uploadedFileData[
'name']),
981 'type' => array($uploadedFileData[
'type']),
982 'tmp_name' => array($uploadedFileData[
'tmp_name']),
983 'size' => array($uploadedFileData[
'size'])
986 $resultObjects = array();
987 $numberOfUploadedFilesForPosition = count($uploadedFileData[
'name']);
989 for ($i = 0; $i < $numberOfUploadedFilesForPosition; $i++) {
991 'name' => $uploadedFileData[
'name'][$i],
992 'type' => $uploadedFileData[
'type'][$i],
993 'tmp_name' => $uploadedFileData[
'tmp_name'][$i],
994 'size' => $uploadedFileData[
'size'][$i]
997 if ((
int)$this->dontCheckForUnique === 1) {
998 GeneralUtility::deprecationLog(
'dontCheckForUnique = 1 is deprecated. Use setExistingFilesConflictMode(DuplicationBehavior::REPLACE);. Support for dontCheckForUnique will be removed in TYPO3 CMS 8.');
1003 $fileObject = $targetFolderObject->addUploadedFile($fileInfo, (
string)$this->existingFilesConflictMode);
1004 $fileObject =
ResourceFactory::getInstance()->getFileObjectByStorageAndIdentifier($targetFolderObject->getStorage()->getUid(), $fileObject->getIdentifier());
1006 $this->
getIndexer($fileObject->getStorage())->updateIndexEntry($fileObject);
1008 $resultObjects[] = $fileObject;
1009 $this->internalUploadMap[$uploadPosition] = $fileObject->getCombinedIdentifier();
1010 $this->writelog(1, 0, 1,
'Uploading file "%s" to "%s"', array($fileInfo[
'name'], $targetFolderObject->getIdentifier()));
1011 }
catch (\TYPO3\CMS\Core\Resource\Exception\InsufficientFileWritePermissionsException $e) {
1012 $this->writelog(1, 1, 107,
'You are not allowed to override "%s"!', array($fileInfo[
'name']));
1013 }
catch (\TYPO3\CMS\Core\Resource\Exception\UploadException $e) {
1014 $this->writelog(1, 2, 106,
'The upload has failed, no uploaded file found!',
'');
1015 }
catch (\TYPO3\CMS\Core\Resource\Exception\InsufficientUserPermissionsException $e) {
1016 $this->writelog(1, 1, 105,
'You are not allowed to upload files!',
'');
1017 }
catch (\TYPO3\CMS\Core\Resource\Exception\UploadSizeException $e) {
1018 $this->writelog(1, 1, 104,
'The uploaded file "%s" exceeds the size-limit', array($fileInfo[
'name']));
1019 }
catch (\TYPO3\CMS\Core\Resource\Exception\InsufficientFolderWritePermissionsException $e) {
1020 $this->writelog(1, 1, 103,
'Destination path "%s" was not within your mountpoints!', array($targetFolderObject->getIdentifier()));
1021 }
catch (\TYPO3\CMS\Core\Resource\Exception\IllegalFileExtensionException $e) {
1022 $this->writelog(1, 1, 102,
'Extension of file name "%s" is not allowed in "%s"!', array($fileInfo[
'name'], $targetFolderObject->getIdentifier()));
1023 }
catch (\TYPO3\CMS\Core\Resource\Exception\ExistingTargetFileNameException $e) {
1024 $this->writelog(1, 1, 101,
'No unique filename available in "%s"!', array($targetFolderObject->getIdentifier()));
1025 }
catch (\RuntimeException $e) {
1026 $this->writelog(1, 1, 100,
'Uploaded file could not be moved! Write-permission problem in "%s"?', array($targetFolderObject->getIdentifier()));
1030 return $resultObjects;
1042 if (!$this->isInit || $this->dont_use_exec_commands) {
1045 $theFile = $cmds[
'data'];
1046 if (!@is_file($theFile)) {
1047 $this->writelog(7, 2, 105,
'The file "%s" did not exist!', array($theFile));
1051 if (!isset($cmds[
'target'])) {
1052 $cmds[
'target'] = $fI[
'path'];
1058 $this->writelog(7, 2, 104,
'Destination "%s" was not a directory', array($cmds[
'target']));
1061 if (!$this->actionPerms[
'unzipFile']) {
1062 $this->writelog(7, 1, 103,
'You are not allowed to unzip files',
'');
1065 if ($fI[
'fileext'] !=
'zip') {
1066 $this->writelog(7, 1, 102,
'File extension is not "zip"',
'');
1070 $this->writelog(7, 1, 101,
'You don\'t have full access to the destination directory "%s"!', array($theDest));
1076 $cmd = $this->unzipPath .
'unzip -qq ' . escapeshellarg($theFile) .
' -d ' . escapeshellarg($theDest);
1078 $this->writelog(7, 0, 1,
'Unzipping file "%s" in "%s"', array($theFile, $theDest));
1081 $this->writelog(7, 1, 100,
'File "%s" or destination "%s" was not within your mountpoints!', array($theFile, $theDest));
1097 if (!$this->isInit) {
1101 $uploadPosition = $cmdArr[
'data'];
1102 $fileInfo = $_FILES[
'replace_' . $uploadPosition];
1103 if (empty($fileInfo[
'name'])) {
1104 $this->writelog(1, 2, 108,
'No file was uploaded for replacing!',
'');
1108 $keepFileName = ($cmdArr[
'keepFilename'] == 1) ?
true :
false;
1109 $resultObjects = array();
1112 $fileObjectToReplace = $this->
getFileObject($cmdArr[
'uid']);
1113 $folder = $fileObjectToReplace->getParentFolder();
1114 $resourceStorage = $fileObjectToReplace->getStorage();
1121 if ($keepFileName ===
false) {
1127 $resultObjects[] = $fileObject;
1128 $this->internalUploadMap[$uploadPosition] = $fileObject->getCombinedIdentifier();
1130 $this->writelog(1, 0, 1,
'Replacing file "%s" to "%s"', array($fileInfo[
'name'], $fileObjectToReplace->getIdentifier()));
1132 $this->writelog(1, 1, 107,
'You are not allowed to override "%s"!', array($fileInfo[
'name']));
1134 $this->writelog(1, 2, 106,
'The upload has failed, no uploaded file found!',
'');
1136 $this->writelog(1, 1, 105,
'You are not allowed to upload files!',
'');
1138 $this->writelog(1, 1, 104,
'The uploaded file "%s" exceeds the size-limit', array($fileInfo[
'name']));
1140 $this->writelog(1, 1, 103,
'Destination path "%s" was not within your mountpoints!', array($fileObjectToReplace->getIdentifier()));
1142 $this->writelog(1, 1, 102,
'Extension of file name "%s" is not allowed in "%s"!', array($fileInfo[
'name'], $fileObjectToReplace->getIdentifier()));
1144 $this->writelog(1, 1, 101,
'No unique filename available in "%s"!', array($fileObjectToReplace->getIdentifier()));
1145 }
catch (\RuntimeException $e) {
1148 return $resultObjects;
1157 protected function addFlashMessage(
FlashMessage $flashMessage)
1163 $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
1164 $defaultFlashMessageQueue->enqueue($flashMessage);