Codeigniter - >图像上传第3部分 - >图像验证

时间:2012-04-11 19:36:46

标签: php image codeigniter

我有以下代码,但我不确定如何处理上传错误,因为有多个$this->do_upload

        $location = $_SERVER['DOCUMENT_ROOT'].'/_assets/quote/uploads/';

        $folderName = $this->quote->getCompanyDetails()->companyName;
        $folderName = str_replace(" ", "_", $folderName);
        $folderName = strtolower($folderName);

        $concepts = array('conceptOne','conceptTwo');
        $logo = $folderName.'_logo';

        if(!is_dir($location.$folderName))
        {   
            mkdir($location.$folderName);
            chmod($location.$folderName, 0777);
        }

        //Set File Settings 
          $config['upload_path'] = $location.$folderName; 
          $config['allowed_types'] = 'jpg|png|pdf'; 
          $config['remove_spaces'] = TRUE;
          $config['overwrite'] = TRUE;
          $config['max_size'] = '1024'; 
          $config['max_width'] = '1024'; 
          $config['max_height'] = '768'; 

          $this->load->library('upload', $config);

        // Upload Concepts

        foreach($concepts as $concept)
        {
             $config['file_name'] = $concept;
             $this->upload->initialize($config);
             $this->upload->do_upload($concept);
        }

        //Upload Logo

            $config['file_name'] = $logo;
             $this->upload->initialize($config);
             $this->upload->do_upload('logo');

1 个答案:

答案 0 :(得分:1)

 // Upload Concepts
    foreach($concepts as $concept)
    {
         $config['file_name'] = $concept;
         $this->upload->initialize($config);
         if ( ! $this->upload->do_upload($concept))
         {
           $error = array('error' => $this->upload->display_errors());
           break;
         }
    }