diff --git a/core/modules/media_library/src/Form/MediaLibraryUploadForm.php b/core/modules/media_library/src/Form/MediaLibraryUploadForm.php
index 0209fda639bd4be9b09e1fde6055ed36d8b99d30..ac250b1077c49ed1f6908f7dea350c68eb39a6a2 100644
--- a/core/modules/media_library/src/Form/MediaLibraryUploadForm.php
+++ b/core/modules/media_library/src/Form/MediaLibraryUploadForm.php
@@ -127,10 +127,10 @@ public function buildForm(array $form, FormStateInterface $form_state) {
         '#description' => $this->t('Upload files here to add new media.'),
         '#upload_validators' => $upload_validators,
       ];
-      $remaining = $this->getRequest()->query->get('media_library_remaining');
-      if ($remaining) {
-        $form['upload']['#multiple'] = $remaining > 1;
-        $form['upload']['#cardinality'] = $form['upload_help']['#cardinality'] = (int) $remaining;
+      $remaining = (int) $this->getRequest()->query->get('media_library_remaining');
+      if ($remaining || $remaining === FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED) {
+        $form['upload']['#multiple'] = $remaining > 1 || $remaining === FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED;
+        $form['upload']['#cardinality'] = $form['upload_help']['#cardinality'] = $remaining;
       }
     }
     else {
diff --git a/core/modules/media_library/tests/src/FunctionalJavascript/MediaLibraryTest.php b/core/modules/media_library/tests/src/FunctionalJavascript/MediaLibraryTest.php
index 21b2a4647f679373b270e25ba949ea0075dbc9ca..9ae45c3a88c3e7606e53080e7865bfa2176e54ca 100644
--- a/core/modules/media_library/tests/src/FunctionalJavascript/MediaLibraryTest.php
+++ b/core/modules/media_library/tests/src/FunctionalJavascript/MediaLibraryTest.php
@@ -356,6 +356,10 @@ public function testWidgetUpload() {
     $unlimited_button->click();
     $assert_session->assertWaitOnAjaxRequest();
 
+    // Multiple uploads should be allowed.
+    // @todo Add test when https://github.com/minkphp/Mink/issues/358 is closed
+    $this->assertTrue($assert_session->fieldExists('Upload')->hasAttribute('multiple'));
+
     $page->attachFileToField('Upload', $this->container->get('file_system')->realpath($png_image->uri));
     $assert_session->assertWaitOnAjaxRequest();
     $page->fillField('Name', 'Unlimited Cardinality Image');