0

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  |
+----------+
Dave
  • 1
  • 1
  • 3

1 Answers1

1

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');
}
Community
  • 1
  • 1
Brad
  • 1,685
  • 1
  • 27
  • 38
  • Hi thanks for the reply I already code the upload script but here is m problem Do you know how to update the image? and replace the image file in location with new one and delete the old image? – Dave Mar 04 '11 at 04:39
  • Please see the edited response above. I hope it helps. I may not be understanding what you are doing – Brad Mar 06 '11 at 05:10