The file uploads successfully to localhost, but it cannot work on the server using CI

When I try to upload image files to localhost, they are stored in DB and I can read these uploaded images, but when I upload the code to the server via FTP, it said an error like this:

  • This page doesn't work.
  • Blablabal.com is currently unable to process this request.
  • HTTP ERROR 500



Is it because my php version on localhost is different from the PHP version on the server?

Can anyone help me? Thanks mate

My controller

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class News extends CI_Controller {
function __construct() {
    parent::__construct();
    $this->load->model('news_model');
        $this->load->helper(array('form', 'url'));
    $this->load->library('session');
}

    public function index()
{
$data['datax'] = $this->news_model->tampil_data()->result();
$data['viewx']="news/content";
$this->load->view('template/header');
$this->load->view('template/main',$data);
  //$this->load->view('news/content');
  $this->load->view('template/footer');
}

    function tambah(){
$data['title'] = "Tambah news";
$data['updateid'] = '';
$data['update'] = '';
$data['viewx']="news/form";
$this->load->view('template/header');
$this->load->view('template/main',$data);
  //$this->load->view('news/content');
  $this->load->view('template/footer');

    }

    function tambah_aksi(){
        //upload
          // $this->load->library('upload');
          $this->load->library('upload');
        $nmfile = "file_".time(); //nama file saya beri nama langsung dan diikuti fungsi time
        $config['upload_path'] = './../assets/'; //path folder
        $config['allowed_types'] = 'gif|jpg|png|jpeg|bmp'; //type yang dapat diakses bisa anda sesuaikan
        $config['max_size'] = '2048'; //maksimum besar file 2M
        $config['max_width']  = '1288'; //lebar maksimum 1288 px
        $config['max_height']  = '768'; //tinggi maksimu 768 px
        $config['file_name'] = $nmfile; //nama yang terupload nantinya
        $this->upload->initialize($config);

        if($_FILES['images']['name'])
        {
            if ($this->upload->do_upload('images'))
            {
                $gbr = $this->upload->data();
               // $data = array(
               //   'nm_gbr' =>$gbr['file_name'],
               //   'tipe_gbr' =>$gbr['file_type'],
                //  'ket_gbr' =>$this->input->post('textket')
                //);

                 //akses model untuk menyimpan ke database
                        $data = array();
                        //insert
                        $judul = $this->input->post('judul');
                        $news = $this->input->post('news');
                        $imagess = $this->input->post('images');
                        $data = array(
                        'title' => $judul,
                            'detail' => $news,
                            'images' => $gbr['file_name']
                         );
                        $this->news_model->input_data($data,"news");
                //pesan yang muncul jika berhasil diupload pada session flashdata
                $this->session->set_flashdata("pesan", "<div class=\"col-md-12\"><div class=\"alert alert-success\" id=\"alert\">Upload gambar berhasil !!</div></div>");
                redirect('news/'); //jika berhasil maka akan ditampilkan view vupload
            }else{
                //pesan yang muncul jika terdapat error dimasukkan pada session flashdata
                $this->session->set_flashdata("pesan", "<div class=\"col-md-12\"><div class=\"alert alert-danger\" id=\"alert\">Gagal upload gambar !!</div></div>");
                redirect('news/tambah'); //jika gagal maka akan ditampilkan form upload
            }
        }
    }

      



I am trying to change my php version and this is what I got

An unrelated exception was caught

Type: error

Message: Call to undefined function finfo_open ()

+3


source to share


3 answers


I am replacing all old CI files except for the MVC folder and config. And then he mends like a magic lol



0


source


same problem i got in the past and i have a solution i replaced my current system / libraries / upload.php file with my old ci 3.0.4 version



+1


source


Possible problems mentioned below

  • Invalid file upload path.
  • The server may have a file size limit set and you upload a file that exceeds that limit. Also, check these settings on your server: max_execution_time, max_input_time, upload_max_filesize, memory_limit

  • File permissions problem.

First of all, check if your file upload directory has permission 755 OR 777. If not change to 755 and try again.

If that doesn't solve the problem, have a look at this: Codeigniter download file does not work on the internet, but rather runs on localhost

0


source







All Articles