CodeIgniter Forums
deleting a file? - 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: deleting a file? (/showthread.php?tid=43796)



deleting a file? - El Forum - 07-23-2011

[eluser]dadamssg[/eluser]
I'm trying to delete/unlink a file. I don't know if the error is being cause by codeigniter or not. I don't know if codigniter has its own unlink function. I couldn't find one.

I'm getting this error:

A PHP Error was encountered

Severity: Warning

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

Filename: controllers/slideshows.php

Line Number: 151


anybody have any suggestions?

edit for more information:

i'm using this to upload and its working. --- $config['upload_path'] = './photos/';

and i've tried this

Code:
$photo = $this->photos_model->get_photo($photo_id);
        $photo_name = $photo['name'];
        
        $file = "./photos/$photo_name";
        
        //delete file from directory
        unlink($file);

but i'm getting this errror

A PHP Error was encountered

Severity: Warning

Message: unlink(./photos/10_1311449383_2.jpg) [function.unlink]: No such file or directory

Filename: controllers/slideshows.php

Line Number: 152

i don't think i'm referencing the directory right...


deleting a file? - El Forum - 07-23-2011

[eluser]dadamssg[/eluser]
nevermind! i'm an idiot.

I eventually got the path right without knowing it and it was deleting. BUT i hadn't written a function to delete the photo record from the db, hence the second error in my original post.