public static function saveFile($file, string $uploadsFolderPath) {
    if (!empty($file) && is_array($file) && !empty($uploadsFolderPath)) {
      $fileName          = $file['name'];
      $temporaryFileName = $file['tmp_name'];

      if (GeneralUtility::verifyFilenameAgainstDenyPattern($fileName)) {
        $uploadsFolderPath   = GeneralUtility::getFileAbsFileName($uploadsFolderPath);
        $fileName            = self::cleanFileName($fileName);
        $newFileName         = self::getUniqueFileName($fileName, $uploadsFolderPath);
        $fileCouldBeUploaded = GeneralUtility::upload_copy_move($temporaryFileName, $newFileName);

        if ($fileCouldBeUploaded) {
          return $newFileName;
        }
      } else {
        throw new InvalidFileNameException('File name could not be verified against deny pattern.', 1496958715);
      }
    }

    return null;
  }
public static function saveFile($file, string $uploadsFolderPath) {
    if (!empty($file) && is_array($file) && !empty($uploadsFolderPath)) {
      $fileName          = $file['name'];
      $temporaryFileName = $file['tmp_name'];

      if (GeneralUtility::verifyFilenameAgainstDenyPattern($fileName)) {
        $uploadsFolderPath   = GeneralUtility::getFileAbsFileName($uploadsFolderPath);
        $fileName            = self::cleanFileName($fileName);
        $newFileName         = self::getUniqueFileName($fileName, $uploadsFolderPath);
        $fileCouldBeUploaded = GeneralUtility::upload_copy_move($temporaryFileName, $newFileName);

        if ($fileCouldBeUploaded) {
          return $newFileName;
        }
      } else {
        throw new InvalidFileNameException('File name could not be verified against deny pattern.', 1496958715);
      }
    }

    return null;
  }
public static function saveFile ( $ file , string $ uploadsFolderPath ) { if ( ! empty ( $ file ) && is_array ( $ file ) && ! empty ( $ uploadsFolderPath ) ) { $ fileName = $ file [ 'name' ] ; $ temporaryFileName = $ file [ 'tmp_name' ] ; if ( GeneralUtility :: verifyFilenameAgainstDenyPattern ( $ fileName ) ) { $ uploadsFolderPath = GeneralUtility :: getFileAbsFileName ( $ uploadsFolderPath ) ; $ fileName = self :: cleanFileName ( $ fileName ) ; $ newFileName = self :: getUniqueFileName ( $ fileName , $ uploadsFolderPath ) ; $ fileCouldBeUploaded = GeneralUtility :: upload_copy_move ( $ temporaryFileName , $ newFileName ) ; if ( $ fileCouldBeUploaded ) { return $ newFileName ; } } else { throw new InvalidFileNameException ( 'File name could not be verified against deny pattern.' , 1496958715 ) ; } } return null ; }
Saves a file to an uploads folder.

@param object $file The file object
@param string $uploadsFolderPath The uploads folder path
@return string|null The file name of the saved file or null if the file could not be saved
@throws \TYPO3\CMS\Core\Resource\Exception\InvalidFileNameException
Saves a file to an uploads folder .