display_errors() public method

Display the error message
public display_errors ( string $open = '<p>', string $close = '</p>' ) : string
$open string
$close string
return string
 /**
  * @param string $file_name
  * @return boolean
  */
 public function upload($file_name)
 {
     $path = $this->_nuevoDirectorio();
     $config = array('upload_path' => $path, 'allowed_types' => 'gif|jpg|png|bmp|doc|docx|pdf|xls|xlsx|txt|ppt|pptx|csv', 'max_size' => '0', 'max_width' => '0', 'max_height' => '0');
     $this->upload = new CI_Upload($config);
     if (!$this->upload->do_upload($file_name)) {
         rmdir($path);
         $this->_error = $this->upload->display_errors();
         return false;
     } else {
         $data = $this->upload->data();
         $relative_path = str_replace(realpath(BASEPATH . "../"), "", realpath($data["full_path"]));
         $relative_path = substr($relative_path, 1, strlen($relative_path));
         $insert = array("arch_c_tamano" => $data["file_size"], "arch_c_nombre" => $relative_path, "arch_c_mime" => $data["file_type"], "arch_c_hash" => $this->_fileHash(), "arch_f_fecha" => DATE("Y-m-d H:i:s"), "usu_ia_id" => $this->session->userdata('session_idUsuario'));
         $this->_archivo_model->query()->insert($insert);
         return true;
     }
 }
Example #2
0
 public static function upload($field, $id, $path, $config = array())
 {
     $CI =& get_instance();
     $ciConfig = $CI->config->item('utils');
     $config['upload_path'] = $ciConfig['file_dir'] . $path . '/';
     $config['allowed_types'] = '*';
     $config['file_name'] = self::getFileName($id, $path) . '.backup';
     $CI->load->library('upload');
     $upload = new CI_Upload($config);
     if (!$upload->do_upload($field)) {
         return $upload->display_errors('', '');
     } else {
         return TRUE;
     }
 }
Example #3
0
 function submit($submit)
 {
     try {
         if ($submit == 'generate_express') {
             $article_ids = preg_split('/,[\\s]*/', $this->input->post('articles'));
             if (!is_array($article_ids)) {
                 $this->output->message('文章id解析错误');
                 throw new Exception();
             }
             $config['upload_path'] = './images/mail/express';
             $config['encrypt_name'] = true;
             $config['allowed_types'] = 'jpg';
             $this->load->library('upload', $config);
             if (!$this->upload->do_upload('header')) {
                 $this->output->message($this->upload->display_errors(), 'warning');
                 throw new Exception();
             }
             $header = $this->upload->data();
             $config['allowed_types'] = 'pdf';
             $config['encrypt_name'] = false;
             $Attachment = new CI_Upload($config);
             if (!$Attachment->do_upload('attachment')) {
                 $this->output->message($Attachment->display_errors(), 'warning');
                 //throw new Exception;
             }
             //$attachment=$Attachment->data();
             $articles = $this->mail->getArticles('star', $article_ids);
             $this->load->addViewData('title', $this->input->post('title'));
             $this->load->addViewData('articles', $articles);
             $this->load->addViewData('header_img', $header['file_name']);
             $mail_html = $this->load->view('mail/express_template', true);
             $this->user->setConfig('mail/express/mail_html', $mail_html);
             $this->user->setConfig('mail/express/title', '星瀚律师 - ' . $this->input->post('title'));
             //$this->session->set_userdata('mail/express/attachment','./images/mail/express/'.$attachment['file_name']);
             $this->output->setData($mail_html, 'preview', 'html', '#express-preview');
         }
         if ($submit == 'send_express') {
             if (!$this->config->user_item('mail/express/mail_html')) {
                 $this->output->message('还没有生成期刊');
                 throw new Exception();
             }
             if (!$this->input->post('client-emails')) {
                 $client_emails = $this->config->user_item('mail/express/receivers');
             } else {
                 $client_emails = preg_split('/,[\\s]*/', $this->input->post('client-emails'));
                 $this->user->setConfig('mail/express/receivers', json_encode($client_emails));
             }
             $this->load->library('email');
             $config = array('protocol' => 'smtp', 'smtp_host' => 'smtp.exmail.qq.com', 'smtp_user' => '*****@*****.**', 'smtp_pass' => '1218xinghan', 'mailtype' => 'html', 'crlf' => "\r\n", 'newline' => "\r\n");
             $this->email->initialize($config);
             $this->email->from('*****@*****.**', '星瀚律师');
             $this->email->subject($this->config->user_item('mail/express/title'));
             $this->email->message($this->config->user_item('mail/express/mail_html'));
             //$this->email->attach($this->session->userdata('mail/express/attachment'));
             if ($this->config->user_item('mail/express/send_progress') < count($this->config->user_item('mail/express/receivers'))) {
                 $receivers = $this->config->user_item('mail/express/receivers');
                 $receiver = $receivers[$this->config->user_item('mail/express/send_progress')];
                 if ($this->email->to($receiver)) {
                     $delivery_status = '';
                 } else {
                     $delivery_status = '(x)';
                 }
                 $this->output->setData($receiver . ' ', 'receiver', 'html', '#delivery-status', 'append');
                 $this->email->send();
                 sleep(3);
                 $this->user->setConfig('mail/express/send_progress', $this->config->user_item('mail/express/send_progress') + 1);
                 $this->output->setData('$(\'[name="submit[send_express]"]:first\').trigger(\'click\')', 'script', 'script');
             } else {
                 $this->output->message('发送完毕');
             }
         }
         if ($submit == 'download') {
             $this->output->as_ajax = false;
             $this->load->model('document_model', 'document');
             $this->document->exportHead('express.html');
             $this->output->set_output($this->config->user_item('mail/express/mail_html'));
         }
         $this->output->status = 'success';
     } catch (Exception $e) {
         $this->output->status = 'fail';
     }
 }
Example #4
0
 /**
  * 
  * @param string|integer $id (Primary Key)
  * @param string $name
  * @param string $folder (posts/images)
  * @return boolean
  */
 public static function upload($field, $id, $name, $folder, $config = array())
 {
     $CI =& get_instance();
     $ciConfig = $CI->config->item('utils');
     $config['upload_path'] = $path = $ciConfig['upload_dir'] . $folder . '/';
     $config['allowed_types'] = 'gif|jpg|png';
     $config['file_name'] = $fileName = self::getFileName($id, self::IMAGE_ORIGINAL, $name);
     $CI->load->library('upload');
     $CI->load->library('image_lib');
     $upload = new CI_Upload($config);
     if (!$upload->do_upload($field)) {
         return $upload->display_errors('', '');
     } else {
         $imageConfig = array('source_image' => $path . $fileName);
         foreach (array(self::IMAGE_LARGE, self::IMAGE_MEDIUM, self::IMAGE_SMALL) as $size) {
             $imageConfig['new_image'] = $path . self::getFileName($id, $size, $name);
             //                list($imageConfig['width'], $imageConfig['height']) = explode('x', $ciConfig['image'][strtolower($size)]);
             list($imageConfig['width']) = explode('x', $ciConfig['image'][strtolower($size)]);
             $image = new CI_Image_lib();
             $image->initialize($imageConfig);
             $image->resize();
             $image->clear();
         }
         $imageConfig['new_image'] = $path . self::getFileName($id, self::IMAGE_THUMB, $name);
         list($imageConfig['width'], $imageConfig['height']) = explode('x', $ciConfig['image'][strtolower(self::IMAGE_THUMB)]);
         $imageConfig['maintain_ratio'] = FALSE;
         $image = new CI_Image_lib();
         $image->initialize($imageConfig);
         $image->resize();
         $image->clear();
         return TRUE;
     }
 }
Example #5
0
 /**
  * More verbose error message for debugging. Too hard to track down file's mime.
  */
 function display_errors($open = '<p>', $close = '</p>')
 {
     $str = parent::display_errors($open, $close);
     $str .= ' (Type: ' . $this->file_type . ' / Ext: ' . $this->file_ext . ')';
     return $str;
 }