Ejemplo n.º 1
0
 /**
  * @group push_uploaded_file_keys
  */
 public function test_push_uploaded_file_keys()
 {
     $this->Data->set(MWF_Config::UPLOAD_FILE_KEYS, array('file1'));
     $this->Data->push_uploaded_file_keys(array('file1' => 'http://exemple.com/dummy.txt'));
     $this->assertSame(array('file1'), $this->Data->get_post_value_by_key(MWF_Config::UPLOAD_FILE_KEYS));
     $this->Data->set(MWF_Config::UPLOAD_FILE_KEYS, array('file1'));
     $this->Data->push_uploaded_file_keys(array('file2' => 'http://exemple.com/dummy.txt'));
     $this->assertSame(array('file1', 'file2'), $this->Data->get_post_value_by_key(MWF_Config::UPLOAD_FILE_KEYS));
 }
Ejemplo n.º 2
0
 /**
  * ファイルアップロード処理。実際のアップロード状況に合わせてフォームデータも再生成する。
  */
 protected function file_upload()
 {
     $File = new MW_WP_Form_File();
     $files = array();
     $upload_files = $this->Data->get_post_value_by_key(MWF_Config::UPLOAD_FILES);
     if (!is_array($upload_files)) {
         $upload_files = array();
     }
     foreach ($upload_files as $key => $file) {
         if ($this->Validation->single_check($key)) {
             $files[$key] = $file;
         }
     }
     $uploaded_files = $File->upload($files);
     $this->Data->set_upload_file_keys();
     $this->Data->push_uploaded_file_keys($uploaded_files);
 }