Browse Source

[ZF-9068] Zend_File_Transfer:

- allow to set options before file integration

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@20902 44c647ce-9c0f-0410-b52a-842ac1e357ba
thomas 16 năm trước cách đây
mục cha
commit
59640d16d3

+ 6 - 2
library/Zend/File/Transfer/Adapter/Abstract.php

@@ -553,6 +553,10 @@ abstract class Zend_File_Transfer_Adapter_Abstract
         $file = $this->_getFiles($files, false, true);
 
         if (is_array($options)) {
+            if ($file === null) {
+                $this->_options = array_merge($this->_options, $options);
+            }
+
             foreach ($options as $name => $value) {
                 foreach ($file as $key => $content) {
                     switch ($name) {
@@ -1274,8 +1278,8 @@ abstract class Zend_File_Transfer_Adapter_Abstract
 
         if (class_exists('finfo', false)) {
             $const = defined('FILEINFO_MIME_TYPE') ? FILEINFO_MIME_TYPE : FILEINFO_MIME;
-            if (!empty($magicFile)) {
-                $mime = new finfo($const, $magicFile);
+            if (!empty($value['options']['magicFile'])) {
+                $mime = new finfo($const, $value['options']['magicFile']);
             } else {
                 $mime = new finfo($const);
             }

+ 1 - 4
library/Zend/File/Transfer/Adapter/Http.php

@@ -49,12 +49,9 @@ class Zend_File_Transfer_Adapter_Http extends Zend_File_Transfer_Adapter_Abstrac
             throw new Zend_File_Transfer_Exception('File uploads are not allowed in your php config!');
         }
 
+        $this->setOptions($options);
         $this->_prepareFiles();
         $this->addValidator('Upload', false, $this->_files);
-
-        if (is_array($options)) {
-            $this->setOptions($options);
-        }
     }
 
     /**