Skip to content

Commit

Permalink
unlink upload files when request dustruct
Browse files Browse the repository at this point in the history
  • Loading branch information
walkor authored Dec 10, 2021
1 parent e344c9f commit d6af94d
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions Protocols/Http/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -650,16 +650,13 @@ public function __destruct()
{
if (isset($this->_data['files'])) {
\clearstatcache();
foreach ($this->_data['files'] as $items) {
if (!\is_array(\current($items))) {
$items = [$items];
}
foreach ($items as $item) {
if (\is_file($item['tmp_name'])) {
\unlink($item['tmp_name']);
\array_walk_recursive($this->_data['files'], function($value, $key){
if ($key === 'tmp_name') {
if (\is_file($value)) {
\unlink($value);
}
}
}
});
}
}
}

0 comments on commit d6af94d

Please sign in to comment.