mirror of
https://github.com/getgrav/grav.git
synced 2025-12-05 15:29:57 +01:00
Add FormFlash::clearFiles() method
This commit is contained in:
@@ -229,7 +229,7 @@ trait FlexMediaTrait
|
||||
$preg_name = preg_quote($fileParts['filename'], '`');
|
||||
$preg_ext =preg_quote($fileParts['extension'], '`');
|
||||
$preg_filename = preg_quote($basename, '`');
|
||||
echo $file .' - ';
|
||||
|
||||
if (preg_match("`({$preg_name}@\d+x\.{$preg_ext}(?:\.meta\.yaml)?$|{$preg_filename}\.meta\.yaml)$`", $file)) {
|
||||
$testPath = $targetPath . '/' . $file;
|
||||
if ($locator->isStream($testPath)) {
|
||||
|
||||
@@ -315,6 +315,20 @@ class FormFlash implements \JsonSerializable
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear form flash from all uploaded files.
|
||||
*/
|
||||
public function clearFiles()
|
||||
{
|
||||
foreach ($this->files as $field => $files) {
|
||||
foreach ($files as $name => $upload) {
|
||||
$this->removeTmpFile($upload['tmp_name'] ?? '');
|
||||
}
|
||||
}
|
||||
|
||||
$this->files = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user