Skip to content

Instantly share code, notes, and snippets.

@franklinokech
Created August 25, 2018 12:10
Show Gist options
  • Save franklinokech/e0895be6472680645d3b839ad639d680 to your computer and use it in GitHub Desktop.
Save franklinokech/e0895be6472680645d3b839ad639d680 to your computer and use it in GitHub Desktop.
Code Snippet for uploading images in php
/* file uploading */
$config['upload_path'] = './uploads/intro/';
$config['allowed_types'] = 'gif|jpg|png';
$config['encrypt_name'] = true;
$this->load->library('upload', $config);
if ($this->upload->do_upload('file_to_upload'))
{ $file_data = $this->upload->data();
` $file_name = $file_data['file_name'];
}
else
{
$file_name = 'noimage.jpg';
}
$data = array
( 'name' => $name, 'email' => $email,
'password' => base64_encode($password),
'mobile' => $mobile,
'file_name' => $file_name,
);
$this->intro_model->intro_insert($data);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment