当我尝试在本地主机上上传图像文件时,它存储在数据库中,我可以读取上传的图像,但是当我通过 FTP 将代码上传到服务器时,它显示如下错误:
- This page isn’t working
- blablabal.com is currently unable to handle this request.
- HTTP ERROR 500
那是因为我在 localhost 中的 php 版本与服务器上的 PHP 版本不同吗?
有人能帮我吗?谢谢大佬
我的 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()
最佳答案
我以前遇到过同样的问题,我已经找到了解决方案 我已经用我的旧 ci 版本 3.0.4 替换了我当前的 system/libraries/upload.php 文件
关于php - 图像文件成功上传到本地主机,但它不能在使用 CI 的服务器中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43625821/