Clear fileprg after submit

Is there a way to clear the fileprg plugin? Because when i upload images in my form and there are some fault in the other (text input) fields the form gets back with the errors. The uploaded images are in the temp folder. When i only remove them from temp they are stil in the fileprg plugin and i want to be able to remove one of the images

Get the session-container from the plugin and unset files. Look at the entire session-container, because some more data is included.

Thanks! How do i access the session-container? How does that look like in code?

See: https://github.com/zendframework/zend-mvc-plugin-fileprg/blob/cdd0af4102efc7abebf8ab24e5bf7e67504a9dbf/src/FilePostRedirectGet.php#L165-L168

Someting like print_r($this->FilePostRedirectGet->getSessionContainer());

Why FilePostRedirectGet? The plugin must be used with the same name as usual fileprg.

$this->plugin('fileprg')->getSessionContainer();

Yes thats it! I can print it now, now searching for the correct entries

I can print, but i cant see where the file is stored and so where to remove…

Zend\Session\Container Object ( [name:protected] => file_prg_post1 [manager:protected] => Zend\Session\SessionManager Object ( [defaultDestroyOptions:protected] => Array ( [send_expire_cookie] => 1 [clear_storage] => ) [defaultOptions:protected] => Array ( [attach_default_validators] => 1 ) [defaultValidators:protected] => Array ( [0] => Zend\Session\Validator\Id ) [name:protected] => [validatorChain:protected] => Zend\Session\ValidatorChain Object ( [events:protected] => Array ( [session.validate] => Array ( [1] => Array ( [0] => Array ( [0] => Array ( [0] => Zend\Session\Validator\Id Object ( [id:protected] => ijaeictcaka3cjn41j5310s9ad ) [1] => isValid ) [1] => Array ( [0] => Zend\Session\Validator\RemoteAddr Object ( [data:protected] => ::1 ) [1] => isValid ) [2] => Array ( [0] => Zend\Session\Validator\HttpUserAgent Object ( [data:protected] => Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36 ) [1] => isValid ) ) ) ) ) [eventPrototype:protected] => Zend\EventManager\Event Object ( [name:protected] => [target:protected] => [params:protected] => Array ( ) [stopPropagation:protected] => ) [identifiers:protected] => Array ( ) [sharedManager:protected] => [storage:protected] => Zend\Session\Storage\SessionArrayStorage Object ( ) ) [config:protected] => Zend\Session\Config\SessionConfig Object ( [knownSaveHandlers:protected] => [phpErrorCode:protected] => [phpErrorMessage:protected] => [rememberMeSeconds:protected] => 1209600 [saveHandler:protected] => [serializeHandler:protected] => [validCacheLimiters:protected] => Array ( [0] => [1] => nocache [2] => public [3] => private [4] => private_no_expire ) [validHashBitsPerCharacters:protected] => Array ( [0] => 4 [1] => 5 [2] => 6 ) [validSidBitsPerCharacters:protected] => Array ( [0] => 4 [1] => 5 [2] => 6 ) [validHashFunctions:protected] => [name:protected] => [savePath:protected] => [cookieLifetime:protected] => 3600 [cookiePath:protected] => [cookieDomain:protected] => [cookieSecure:protected] => [cookieHttpOnly:protected] => [useCookies:protected] => [options:protected] => Array ( [gc_maxlifetime] => 2592000 ) ) [defaultConfigClass:protected] => Zend\Session\Config\SessionConfig [storage:protected] => Zend\Session\Storage\SessionArrayStorage Object ( ) [defaultStorageClass:protected] => Zend\Session\Storage\SessionArrayStorage [saveHandler:protected] => [validators:protected] => Array ( [0] => Zend\Session\Validator\Id [1] => Zend\Session\Validator\RemoteAddr [2] => Zend\Session\Validator\HttpUserAgent ) ) [defaultValue:Zend\Session\AbstractContainer:private] => [storage:protected] => Array ( ) [flag:protected] => 2 [iteratorClass:protected] => ArrayIterator [protectedProperties:protected] => Array ( [0] => name [1] => manager [2] => storage [3] => flag [4] => iteratorClass [5] => protectedProperties ) )

Based on your first post, you must clear files. Compare with: https://github.com/zendframework/zend-mvc-plugin-fileprg/blob/cdd0af4102efc7abebf8ab24e5bf7e67504a9dbf/src/FilePostRedirectGet.php#L157-L160

Sorry, but your output from the session-container can nobody read. Please use the code tags.

Yeah, code below empties the files.

$test = $this->plugin(‘fileprg’)->getSessionContainer();
unset($test->files);

To make it more complex, there are 5 files possible, so what if i have to remove eg. file number 3

files should be an array, so nothing is complex. :wink:

Yes i know, but how to access it :slight_smile: if i can print it i can see the structure

If you can print it, you already have access.

$this->plugin(‘fileprg’)->getSessionContainer()->files;

You can change the values here. That’s it. No more and no less.

pffff i make it to difficult for myself! Thanks for the help!