CodeIgniter Forums
Help, I cannot Unlink - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Help, I cannot Unlink (/showthread.php?tid=37311)



Help, I cannot Unlink - El Forum - 01-05-2011

[eluser]konank[/eluser]
Please help me,
I'm Cannot unlink

This my code in model..

Code:
public function delete_data_siswa($id,$img1,$img2)
        {
            $path = "".base_url()."images/".$img1;
            $path2 = "".base_url()."images/thumbs/".$img2;
            
            $data = $this->db->where('id',$id);
            $data = $this->db->delete('absensi_data_siswa');
            unlink($path);
            unlink($path2);
            return $data;
          
        }


error :
Code:
A PHP Error was encountered

Severity: Warning

Message: unlink() [function.unlink]: http does not allow unlinking

Filename: models/db_model.php



Help, I cannot Unlink - El Forum - 01-05-2011

[eluser]smilie[/eluser]
Unlink can _only_ delete localfile - not a remote one.

So:
unlink('http://whatever/file.txt') will fail;
unlink('/var/www/file.txt') works (if PHP has privileges to delete that file).

Cheers,
Smilie


Help, I cannot Unlink - El Forum - 01-05-2011

[eluser]konank[/eluser]
Yes...!!
i'ts works..

now I understand..
I just has to change my code like this :

Code:
$path = "".base_url()."images/".$img1;
$path2 = "".base_url()."images/thumbs/".$img2;

unlink($path);
unlink($path2);

To

unlink("images/".$img1."");
unlink("images/thumbs/".$img2."");

Thank You..
Smile