CoreCommunity ExtensionsIncubatorDistributionsTYPO3 4.5 ProjectsTYPO3 4.6 ProjectsTYPO3 4.7 ProjectsTYPO3 6.0 ProjectsTYPO3 6.1 ProjectsTYPO3 6.2 Projects (+)

Bug #4232

FileMinCount check not working

Added by Frank Mueller almost 4 years ago. Updated over 2 years ago.

Status:Closed Start date:2009-08-12
Priority:Must have Due date:
Assignee:Reinhard Führicht % Done:

100%

Category:-
Target version:-
Votes: 0

Description

you have to change the following in file Tx_Formhandler_ErrorCheck_FileMinCount.php
------------------------
if( is_array($_SESSION['formhandlerFiles'][$name]) &&
count($_SESSION['formhandlerFiles'][$name]) < $minCount &&
$_SESSION['formhandlerSettings']['currentStep'] == $_SESSION['formhandlerSettings']['lastStep']) {

$checkFailed = $this->getCheckFailed($check);
} elseif (is_array($_SESSION['formhandlerFiles'][$name]) &&
$_SESSION['formhandlerSettings']['currentStep'] > $_SESSION['formhandlerSettings']['lastStep']) {
foreach($_FILES as $idx => $info) {
if(strlen($info['name'][$name]) > 0 && count($_SESSION['formhandlerFiles'][$name]) < $minCount) {
$checkFailed = $this->getCheckFailed($check);
}
}
}
--------------------------
into this:
--------------------------
if (is_array($_SESSION['formhandlerFiles'][$name]) &&
$_SESSION['formhandlerSettings']['currentStep'] > $_SESSION['formhandlerSettings']['lastStep']) {
foreach($_FILES as $idx => $info) {
if(strlen($info['name'][$name]) > 0 && count($_SESSION['formhandlerFiles'][$name]) < $minCount) {
$checkFailed = $this->getCheckFailed($check);
}
}
}
--------------------------

cause this validation doesn't make sense until the last step! otherwise you get an error after the first file upload!

History

Updated by Frank Mueller almost 4 years ago

you have to change the following in file Tx_Formhandler_ErrorCheck_FileMinCount.php

if(is_array($_SESSION['formhandlerFiles'][$name]) &&
count($_SESSION['formhandlerFiles'][$name]) < $minCount &&
$_SESSION['formhandlerSettings']['currentStep'] == $_SESSION['formhandlerSettings']['lastStep']) {

    $checkFailed = $this->getCheckFailed($check);
} elseif (is_array($_SESSION['formhandlerFiles'][$name]) &&
    $_SESSION['formhandlerSettings']['currentStep'] > $_SESSION['formhandlerSettings']['lastStep']) {

    foreach($_FILES as $idx => $info) {
        if(strlen($info['name'][$name]) > 0 && count($_SESSION['formhandlerFiles'][$name]) < $minCount) {
            $checkFailed = $this->getCheckFailed($check);
        }
    }

}

into this:

if (is_array($_SESSION['formhandlerFiles'][$name]) &&
$_SESSION['formhandlerSettings']['currentStep'] > $_SESSION['formhandlerSettings']['lastStep']) {

    foreach($_FILES as $idx => $info) {
        if(strlen($info['name'][$name]) > 0 && count($_SESSION['formhandlerFiles'][$name]) < $minCount) {
            $checkFailed = $this->getCheckFailed($check);
        }
    }

}

cause this validation doesn't make sense until the last step! otherwise you get an error after the first file upload!

Updated by Reinhard Führicht almost 4 years ago

  • % Done changed from 50 to 70

I tested the code a bit and you are right.
Changed the code according to your suggestion, but added an additional condition:

if (is_array($_SESSION['formhandlerFiles'][$name]) &&
$_SESSION['formhandlerSettings']['currentStep'] > $_SESSION['formhandlerSettings']['lastStep']) {

    foreach($_FILES as $idx => $info) {
        if(strlen($info['name'][$name]) > 0 && count($_SESSION['formhandlerFiles'][$name]) < ($minCount - 1)) {
            $checkFailed = $this->getCheckFailed($check);
        } elseif(strlen($info['name'][$name]) == 0 && count($_SESSION['formhandlerFiles'][$name]) < $minCount) {
            $checkFailed = $this->getCheckFailed($check);
        }
    }
}

Example: minCount ist set to 2

The user may have uploaded 1 file using the submit_reload and wants to upload the second one by browsing for the file and clicking on "next" to go to the next step. The first condition handles this.
The elseif branch is in case the user uploads all files using submit_reload.

This should work well.
What do you think?

Updated by Reinhard Führicht over 3 years ago

  • Status changed from New to Needs Feedback

Please tell me if this fix works for you, so that I can close this issue.

Updated by Frank Mueller over 3 years ago

it works now! thanks!

Updated by Reinhard Führicht over 3 years ago

  • Status changed from Needs Feedback to Closed
  • % Done changed from 70 to 100

Also available in: Atom PDF