Commit 9f879047 authored by Benni Mack's avatar Benni Mack Committed by Susanne Moog
Browse files

[BUGFIX] Allow to upload online media via file list

It was not possible due to a form name mixup to add online media files
via the FileList in TYPO3 v9 anymore.

Related: #82436
Related: #81763
Resolves: #83151
Releases: master
Change-Id: Ica0ed049f685bf20b98f0a599adf61ec3874017a
Reviewed-on: https://review.typo3.org/54847


Reviewed-by: Andreas Fernandez's avatarAndreas Fernandez <typo3@scripting-base.de>
Tested-by: Andreas Fernandez's avatarAndreas Fernandez <typo3@scripting-base.de>
Tested-by: default avatarTYPO3com <no-reply@typo3.com>
Reviewed-by: Susanne Moog's avatarSusanne Moog <susanne.moog@typo3.org>
Tested-by: Susanne Moog's avatarSusanne Moog <susanne.moog@typo3.org>
parent 1b14468a
......@@ -16,6 +16,7 @@ namespace TYPO3\CMS\Backend\Controller;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Core\Http\RedirectResponse;
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Messaging\FlashMessage;
use TYPO3\CMS\Core\Messaging\FlashMessageService;
......@@ -56,15 +57,15 @@ class OnlineMediaController
}
/**
* Process add media request
* Process add media request, and redirects to the previous page
*
* @param ServerRequestInterface $request
* @param ResponseInterface $response
* @return ResponseInterface
*/
public function mainAction(ServerRequestInterface $request, ResponseInterface $response)
public function mainAction(ServerRequestInterface $request)
{
$files = $request->getParsedBody()['file'];
$files = $request->getParsedBody()['data'];
$redirect = $request->getParsedBody()['redirect'];
$newMedia = [];
if (isset($files['newMedia'])) {
$newMedia = (array)$files['newMedia'];
......@@ -92,18 +93,18 @@ class OnlineMediaController
);
}
$this->addFlashMessage($flashMessage);
if (empty($redirect) && $media['redirect']) {
$redirect = $media['redirect'];
}
}
}
$redirect = isset($request->getParsedBody()['redirect']) ? $request->getParsedBody()['redirect'] : $request->getQueryParams()['redirect'];
$redirect = GeneralUtility::sanitizeLocalUrl($redirect);
if ($redirect) {
$response = $response
->withHeader('Location', GeneralUtility::locationHeaderUrl($redirect))
->withStatus(303);
return new RedirectResponse($redirect, 303);
}
return $response;
throw new \RuntimeException('No redirect after uploading a media found, probably a mis-use of the template not sending the proper Return URL.', 1511945040);
}
/**
......
......@@ -62,7 +62,7 @@
</div>
<div class="form-group">
<input class="btn btn-default" type="submit" value="{f:translate(key: 'LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:online_media.new_media.submit')}" />
<input type="hidden" name="data[newMedia][0][redirect]" value="{returnUrl}" />
<input type="hidden" name="redirect" value="{returnUrl}" />
</div>
</div>
</form>
......
......@@ -219,7 +219,7 @@ class FolderUtilityRenderer
$markup[] = implode(' ', $fileExtList);
$markup[] = '</div>';
$markup[] = '</div>';
$markup[] = '<input type="hidden" name="data[newMedia][0][redirect]" value="' . htmlspecialchars($redirectValue) . '" />';
$markup[] = '<input type="hidden" name="redirect" value="' . htmlspecialchars($redirectValue) . '" />';
$markup[] = '</form>';
$code .= implode(LF, $markup);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment