[英]CodeIgniter not uploading any image when on live server
I am trying to upload a file in CodeIgniter when on live server. 我在实时服务器上尝试在CodeIgniter中上传文件。 It is working perfectly on localhost but when I try to upload it on live server the upload library is not working, can you please tell me what I am doing wrong? 它可以在localhost上正常运行,但是当我尝试将其上传到实时服务器上时,上传库无法正常工作,您能告诉我我做错了什么吗? Do I need to change something in php.ini of live server? 我需要在实时服务器的php.ini中进行更改吗?
Here is my code: 这是我的代码:
public function do_upload()
{
$config = [
'upload_path' => './uploads',
'allowed_types' => 'jpg|gif|png|jpeg',
'max_size' => 1100000000,
'max_width' => 102400000,
'max_height' => 76800000,
];
// print_r($config);
// exit();
$upload= $this->load->library('upload');
$this->load->library('upload', $config);
$this->upload->initialize($config);
// var_dump($config);
var_dump($upload);
// exit();
if(!$this->upload->do_upload('imagefile'))
{
$upload_error = $this->upload->display_errors();
$this->load->view('site/timeline/timeline_profile',compact('upload_error'));
}
else
{
$post = $this->input->post();
unset($post['submit']);
$upload_data = $this->upload->data();
$file_name=$_FILES['imagefile'];
$this->load->model('Timeline_model');
$this->Timeline_model->upload_model($post,$file_name);
echo $image_path= base_url("uploads/".$upload_data['raw_name'].$upload_data['file_ext']);
}
}
on var dump the value it is showing me null. 在var dump上的值显示为null。
请严格按照“ 文件上传类”中的代码进行操作,并且它将确保您具有写入权限以上传服务器中的文件夹。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.