Dave
Dave

Reputation: 1

Codeigniter Image upload

where can i find tutorial where the concept is uploading image and it save the image path in database with the user id and with delete function. thanks!

here are the concept form

+--------+ +------------+
| avatar | |            | Browse
+--------+ +------------+ 

+----------+
|          |  name
+----------+

+----------+
|          |  age  
+----------+

+----------+
|          |  address
+----------+


+----------+
|  Submit  |
+----------+

Upvotes: 0

Views: 1293

Answers (1)

Brad
Brad

Reputation: 1691

Here is one that does the upload, the database and delete should be easy from there

http://net.tutsplus.com/tutorials/php/codeigniter-from-scratch-file-uploading-and-image-manipulation/

Also review the codeigniter pages for this subject

Also of note Codeigniter: Image Upload

EDIT----------------------------------------

I am assuming you are listing the images in a table to edit or delete them. I could be way off base with what you are doing. I am also assuming while you use the "user id" you also assign an id to the image itself.

For deletions I do something like this

$this->table->set_heading('Date', 'Title', 'Delete', 'Update');
 foreach($records as $row){
$row->title = ucwords($row->title);

$this->table->add_row(
$row->date,
anchor("main/blog_view/$row->id", $row->title),    
anchor("main/delete/$row->id", $row->id, array('onClick' => "return confirm('Are you     sure you want to delete?')")),
anchor("main/fill_form/$row->id", $row->id)
);
}
$table = $this->table->generate();

See the second anchor? It picks up the ID of the image in the db and points to a controller function:

 function delete()
{
    $this->is_logged_in();
    $this->post_model->delete_row();
    $this->maint();
}

the Model

   function delete_row()
{
    $this->db->where('id', $this->uri->segment(3));
    $this->db->delete('posts');
}

Upvotes: 1

Related Questions