Reputation: 577
I have AWS instance with Ubuntu and PHP configured. Every things work perfect. Only file upload not working. Application developed in PHP [codeigniter]
$this->load->library('form_validation');
$config = [
'upload_path' => "./data/user-avatar",
'allowed_types' => 'gif|jpg|png|jpeg|JPEG',
'encrypt_name' => TRUE
];
$this->load->library('upload',$config);
if($this->upload->do_upload())
{
$data = $this->upload->data();
echo $image = $data['file_name'];
} else {
echo "I am here in else";
}
It executive else block directly. Application work fine on local.
Any help to find of the error will be appreciated.
Thanks Prashant
Upvotes: 0
Views: 725
Reputation: 92
Did you make sure your max upload size and max post are big enough on php.ini
or your main php config file?
it could not accept files bigger than X;
Also you could get the $data['error']
to see if you get any code > 0 and find a answer from this; maybe $error = $this->upload->display_errors();
could tell you more
Also check if your directory exists, using is_dir()
to make sure you are not pointing to a different relative path (worth the check).
Upvotes: 1