2

空白の画面が表示されます:/最初の画像をアップロードします。それで問題ありません。_create_thumbnail を呼び出すよりも、「$this->image_lib->resize()」行で空白の画面が表示されます:/

何が問題なのですか?

ありがとう!!

/** * ============================================= ==================== * 写真をアップロード *
* サム = 210px - 160px * オリジナル = 500px - 385px * */

function img_upload() 
{
    $config['upload_path'] = 'uploads/';
    $config['allowed_types'] = 'gif|jpg|jpeg|png';
    $config['max_size'] = '1000';
    $config['max_width'] = '1920';
    $config['max_height'] = '1280';     
    $config['width'] = 500;
    $config['height'] = 385;                

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

    if(!$this->upload->do_upload()) echo $this->upload->display_errors();
    else {

        $fInfo = $this->upload->data();
        $this->_create_thumbnail($fInfo['file_name']);

        $data['uploadInfo'] = $fInfo;
        $data['thumbnail_name'] = $fInfo['raw_name'] . '_thumb' . $fInfo['file_ext'];

        // set view
        $this->load->view('upload_success', $data); 
    }
}

function _create_thumbnail($fileName) 
{
    $config['image_library'] = 'gd2';
    $config['source_image'] = 'uploads/' . $fileName;   
    $config['create_thumb'] = TRUE;
    $config['maintain_ratio'] = TRUE;
    $config['width'] = 210;
    $config['height'] = 160;

    $this->load->library('image_lib', $config);
    if(!$this->image_lib->resize()) echo $this->image_lib->display_errors();

}
4

3 に答える 3

1

ここで中括弧を確認してください:

if(!$this->upload->do_upload()) echo $this->upload->display_errors(); else {

構文スタイルを混在させているようです。

于 2009-07-24T16:46:36.647 に答える
0

削除してみてください$fileName:

これの代わりに:$config['source_image'] = 'uploads/' . $fileName;

これを使って:$config['source_image'] = 'uploads/'

于 2010-03-31T08:13:29.457 に答える