I've created a small scale CMS for the website I'm working on and have a form that uploads image files for use on the website. It uploads files successfully but the permissions it sets do not allow files to be viewed in the browser. this is my controller. I am still a beginner using Codeigniter, when running locally there is no problem, when it is uploaded to the server there are problems related to permission problems.
$config['upload_path'] = './assets/backend/img/banner';
$config['allowed_types'] = 'jpg|jpeg|png';
$config['encrypt_name'] = 'True';
$this->load->library('upload', $config);
if (!$this->upload->do_upload('path_banner')) {
$this->session->set_flashdata(
'pesan',
'<div class="alert alert-danger alert-dismissible fade show" role="alert">
<strong>Maaf :(!</strong> Upload gagal, format photo jpg, jpeg, png
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>'
);
redirect('backend/admin/banner');
I not really agree with permission 755 or with the need to do so through the code and not through the operating system.
For your question, you can add that code if do_upload
return true
$full_path = $this->upload->data('full_path');
chmod($full_path, 0755);