unlink a image from its folder ? |
[eluser]meer[/eluser]
can sumone tell me the easy way to unlink an image from the floder my images are deleting from the db(image file name) bt they are still exixting in the image folder im using the following codes view........... <?php foreach($result as $row ) { ?> <tr> <td width="273" height="63" align="center"><img src="<?php echo base_url(); ?>images/<?php echo $row->image; ?>" height="80" width="120" /></td> <td width="261" align="center"><a href="admin_controller/delete/<?php echo $row->id; ?>"><strong>DELETE</strong></a></td> </tr> <tr> <td colspan="2" align="center"><a href="admin_controller/delete/<?php echo $row->id; ?>"></a> ~~~~~~~~~~~~~~~~~~~~~</td> </tr> <?php } ?> controller......... function delete() { $id=$this->uri->segment(3); $this->db->delete('add_images',array('id'=>$id)); } model........ <?php class Admin_model extends CI_Model{ function set_admin() { $this->db->select('id,hover,desc,image,fullpath'); $this->db->from('add_images'); $query = $this->db->get(); //echo $query->result->hover; if($query->num_rows()>0) { //echo "nhuhh"; die; return $query->result(); } else { return false; } } } what will be the best way to do this ......plzzzzzzzzz
[eluser]xeroblast[/eluser]
the answer is here : http://ellislab.com/codeigniter/user-gui...elper.html
[eluser]aquary[/eluser]
it just a normal php function to delete an image....
[eluser]meer[/eluser]
my problem is to unlinking the image from image folder.......
[eluser]meer[/eluser]
i have got the full path bt still im unable to unlink the image from its folder some one plz.....
[eluser]boltsabre[/eluser]
What have you tried yet? Native php unlink(), CI file helper delete_files('path')? Things to keep in mind: - I'd put it in my model, and call it before you delete it from the database. ONLY delete the image from the DB if your file delete is successful. - If you are using php unlink(), the path should be relative to the script that is calling it. So you'll have to navigate down a couple of tree levels, then back up the tree to the folder containing the image. So I'd expect it to look something like this: Code: $delete = unlink("../../images/uploads/thisismyfile.gif"); Code: $delete = delete_files('./path/to/directory/myfile.gif');
|
Welcome Guest, Not a member yet? Register Sign In |