2013-10-02 3 views
0

PHP를 사용하여 큰 이미지 (> 1.5MB 이상)를 내 웹 사이트에 업로드하려고하지만 파일이 서버에 표시되지 않습니다. 때로는 오류 1 (최대 크기 초과)이 발생합니다.CodeIgniter로 큰 이미지를 업로드 할 때 오류가 발생했습니다.

내가 할 수 있는게 있습니까?

 if ($this->input->post('post') == ''){ 
      $type="image"; 
     } else { 
      $type="image-with-text"; 
     } 
    } else { 
     $pic = ""; 
     $type = "text"; 
    } 

    $result = $this->blog->addPost($_SESSION['user_id'], $type , $this->input->post('post'),$pic); 
} 

모델 :

function addPost($user_id, $post_type, $post , $pic) { 
    $today = date("Y-m-d H:i:s"); 
    $vales = array('ev_user_id' => $user_id, 'ev_type' => $post_type, 'ev_text' => $post,'ev_pic' => $pic, 'ev_date' => $today); 
    $this->db->insert($this->table_name, $vales); 
} 

오류 :

여기

$pic = $this->do_upload('inputUpProfile'); 

나는 데이터베이스에 사진을 저장 : 여기

public function do_upload($field) { 
    $config['upload_path'] = './uploads/'; 
    $config['max_size'] = '100000'; 
    $config['max_width'] = '1024'; 
    $config['max_height'] = '768'; 

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

    if (!$this->upload->do_upload($field)) { 
     $error = array('error' => $this->upload->display_errors()); 

     return $error; 
    } else { 
     /*$data = array('upload_data' => $this->upload->data()); 
     return $data;*/ 
     $updata =$this->upload->data(); 
     $data = $updata['raw_name'].$updata['file_ext']; 
     return $data; 
    } 
} 

내가 함수를 호출 할 수 있습니다

Error Number: 1054

Unknown column 'Array' in 'field list'

INSERT INTO events (ev_user_id , ev_type , ev_text , ev_pic , ev_date) VALUES (1, 'image', '', Array, '2013-10-02 23:32:50')

+0

당신이 'ev_pic'를 시도 할 수 => $ 그림 [0] :

이 오류는 데이터베이스에있는 그림 값으로이 호출에서 결과를 사용하여 무엇입니까? –

답변

0

네 번째 값 (Array)이 잘못되었습니다. 파일 이름을 데이터베이스에 저장하려고한다고 가정합니다. CodeIgniter documentation 당신의 $pic 변수에 따라

는 다음 필드 배열을 반환하는 방법 data() 있습니다

Array 
(
    [file_name] => mypic.jpg 
    [file_type] => image/jpeg 
    [file_path] => /path/to/your/upload/ 
    [full_path] => /path/to/your/upload/jpg.jpg 
    [raw_name]  => mypic 
    [orig_name] => mypic.jpg 
    [client_name] => mypic.jpg 
    [file_ext]  => .jpg 
    [file_size] => 22.2 
    [is_image]  => 1 
    [image_width] => 800 
    [image_height] => 600 
    [image_type] => jpeg 
    [image_size_str] => width="800" height="200" 
) 
0

당신은 $의 그림 정의에 문제가를, 두 개의 정의를 가지고있다.

변경이 : 여기에

function addPost($user_id, $post_type, $post , $pic) { 
    $today = date("Y-m-d H:i:s"); 
    $vales = array('ev_user_id' => $user_id, 'ev_type' => $post_type, 'ev_text' => $post,'ev_pic' => $pic, 'ev_date' => $today); 
    $this->db->insert($this->table_name, $vales); 
} 

:

function addPost($user_id, $post_type, $post , $ev_pic) { 
    $today = date("Y-m-d H:i:s"); 
    $vales = array('ev_user_id' => $user_id, 'ev_type' => $post_type, 'ev_text' => $post,'ev_pic' => $ev_pic, 'ev_date' => $today); 
    $this->db->insert($this->table_name, $vales); 
} 

을 주목 $ 그림 $ ev_pic 변화 합니다.

$pic = $this->do_upload('inputUpProfile'); 
+0

나는 바꿀 것이다. 그러나 오류는 여전히 있었다. – kamgfx

관련 문제