3

When i try upload image files in localhost it stored on DB and i can read that uploaded images, but when i upload the code to the server via FTP it said error like this:

  • This page isn’t working
  • blablabal.com is currently unable to handle this request.
  • HTTP ERROR 500



Is that because my php version in localhost is different with the PHP version on the server?

Can someone 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 try change my php version and this is what i got

An uncaught Exception was encountered

Type: Error

Message: Call to undefined function finfo_open()

Budi Haryono
  • 43
  • 2
  • 9

3 Answers3

1

same issue i was fetched in past, and i have got solution i have replace my current system/libraries/upload.php file with my old ci version 3.0.4

Suresh Suthar
  • 794
  • 8
  • 15
0

There are possible problems mentioned below,

  1. File upload path is incorrect.
  2. The server might have file size limit set and you are uploading the file that exceeds that limit. Also, check for these settings on your server: max_execution_time, max_input_time, upload_max_filesize, memory_limit

  3. File permission issue.

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

If it does not resolves the problem then have a look at this: Codeigniter upload file not working online but works on localhost

Community
  • 1
  • 1
abhijeetwebdev
  • 366
  • 1
  • 4
  • 14
0

I replace all the old CI files, except the MVC and config folder. And then it's fix like a magic lol

Budi Haryono
  • 43
  • 2
  • 9