问题
I uploaded my image using codeigniter, uploaded images not displaying in my website, then i went filezilla and searched about that file, the folder permission is 755 but file permission is 600, if i change the file permission to 644, then image displays fine, but i cann't do like this for all uploading images. so, is there any way to fix it?
$config['upload_path'] = './assets/images/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '100';
$config['max_width'] = '600';
$config['max_height'] = '600';
$config['file_name'] = $id;
$this->load->library('upload');
$this->upload->initialize($config);
if(!$this->upload->do_upload())
{
$error = array('error' => $this->upload->display_errors());
redirect('', $error);
}
else
{
chmod($config['upload_path'], 0755);
redirect('');
}
回答1:
This Try Code Change permision Folder Not File
$config['upload_path'] = chmod('./assets/images/', 0755);
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '100';
$config['max_width'] = '600';
$config['max_height'] = '600';
$config['file_name'] = $id;
$this->load->library('upload');
$this->upload->initialize($config);
if(!$this->upload->do_upload())
{
$error = array('error' => $this->upload->display_errors());
redirect('', $error);
}
else
{
$config['upload_path'];
redirect('');
}
回答2:
$config['upload_path'] = './assets/images/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '100';
$config['max_width'] = '600';
$config['max_height'] = '600';
$config['file_name'] = $id;
$uploadata = array('upload_data' => $this->upload->data());
$perfile = $uploadata ['upload_data']['full_path'];
chmod($perfile ,0777)
来源:https://stackoverflow.com/questions/31377917/codeigniter-uploaded-images-permission-is-600-in-web-server-images-not-display