首页 文章

在codeigniter上上传的文件在服务器上不起作用,但在localhost上有效

提问于
浏览
-1

我正在尝试使用codeigniter将文件上传到服务器,但这对我不起作用 . 但是相同的代码在localhost上工作正常 . 文件正在上传成功 .

请先检查我的代码

public function add_new_book()

    {
    echo $image = $_FILES ['bookcover']['name']; 

    $img=$_FILES ['bookcover'];

    $config['upload_path'] = 'uploads'; 

    $config['overwrite'] = 'TRUE';

    $config["allowed_types"] = 'jpg|jpeg|png|gif|pdf';

    $config["max_size"] = '140000';

    $config["max_width"] = '1400';

    $config["max_height"] = '1400';

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



    if(!$this->upload->do_upload('bookfile')) 

    {               
        echo "error file";

        $this->data['error'] = $this->upload->display_errors(); 

        echo json_encode(array("result"=>$this->data['error']));

        exit;

    } 



    if(!$this->upload->do_upload('bookcover')) 

    {               
        echo "error file";

        $this->data['error'] = $this->upload->display_errors(); 

        echo json_encode(array("result"=>$this->data['error']));

        exit;

    } 



    $udata['bookname'] = $this->input->post('bookname');

    $udata['author'] = $this->input->post('author');

    $udata['Description'] = $this->input->post('description'); 

    $udata['coverImage'] =  $_FILES ['bookcover']['name']; 

    $udata['book'] =  $_FILES ['bookfile']['name']; 

    $udata['createddate'] = date("Y-m-d h:i:sa");

    $udata['isavailable'] = '1';

    $res = $this->CreateBook_model->insert_books_to_db($udata); 

    echo json_encode($res);  

 }

相同的代码在localhost上正常工作,但在控制台中获取500内部服务器错误 .

我已经在stackoverflow上查看了与此问题相关的所有问题,但没有任何工作 . 所以请不要认为它重复 . 帮助被批评

1 回答

  • -1

    请在你的php.ini文件中查看这些内容,并确保你上传的内容较小,然后在那里给出:

    max_execution_time
    max_input_time
    upload_max_filesize
    memory_limit
    

相关问题