WepsTech
The world of development
Here you can see the PHP CodeIgniter code for uploading the Image via android or iOS. For iOS you can refer a video. For watching the video please click here.
This post is about CodeIgniter(C.I.) file upload
. By the use of file uploading class, you can easily upload a file or an image. One can easily validate
and restrict file type
, its size and can even provide various preferences
while uploading a file
or image
.Using CodeIgniter
Image Upload example, we will teach you how an image or a file gets uploaded to an upload folder
or a targeted location
.
Below is our complete code with live demo and download code option.
function file_upload() { // key name is file_name $uploads_path='assets/images'; if (!empty($_FILES)) { $config['upload_path'] = $uploads_path; $config['allowed_types'] = 'gif|jpg|png|jpeg'; $config['overwrite'] = FALSE; $config['encrypt_name'] = TRUE; $config['remove_spaces'] = TRUE; $this->load->library('upload', $config); if (!$this->upload->do_upload('file_name')) { $this->data['error'] = array('error' => $this->upload->display_errors()); $arr = array('status' => "invalid", "message" => strip_tags($this->data['error']["error"]), "title" => "invalid", "error" => strip_tags($this->data['error'])); } else { $data = array('upload_data' => $this->upload->data()); $file_name = $data["upload_data"]["file_name"]; $arr = array('status' => "valid", "message" => "Image Uploaded","file_name" => $file_name, "file_path" => $this->base.$file_name); } echo json_encode($arr); } }
SELECT * or SELECT column1, colum2, column3, etc
Good luck 🙂 Happy Coding