Created
December 3, 2014 01:44
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function uploadImage() { | |
$this->load->library('upload'); | |
$imageFolder = 'assets/images/features'; | |
if (!file_exists($imageFolder)) { | |
mkdir($imageFolder, DIR_WRITE_MODE, true); | |
} | |
$this->upload_config = array( | |
'upload_path' => $imageFolder, | |
'allowed_types' => '*', | |
'max_size' => 2048, | |
'remove_space' => TRUE, | |
'encrypt_name' => TRUE | |
); | |
$this->upload->initialize($this->upload_config); | |
if (!$this->upload->do_upload()) { | |
$upload_error = $this->upload->display_errors(); | |
echo json_encode($upload_error); | |
} else { | |
$fileNames= array(); | |
$fileNames= $this->session->userdata('featureImages'); | |
$fileInfo = $this->upload->data(); | |
$fileNames[] = $fileInfo['file_name']; | |
$this->session->set_userdata('featureImages', $fileNames); | |
echo json_encode($fileInfo); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment