Browse Source

unlink upload files when request dustruct

walkor 3 years ago
parent
commit
d6af94dc56
1 changed files with 5 additions and 8 deletions
  1. 5 8
      Protocols/Http/Request.php

+ 5 - 8
Protocols/Http/Request.php

@@ -650,16 +650,13 @@ class Request
     {
         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);
                     }
                 }
-            }
+            });
         }
     }
 }