EllisLab text mark
Advanced Search
     
File helper
Posted: 09 September 2007 11:25 PM   [ Ignore ]
Joined: 2006-07-16
11 posts

Hi all…
I’m working with files… the write_file works fine.. but.. how can I delete a file?
I try with the

$file_delete '/var/www/xmlrpc/listas/'.$nombre_lista.".txt";
delete_files($file_delete); 

but does not work… so.. I try with the unlink

$file_delete '/var/www/xmlrpc/listas/'.$nombre_lista.".txt";
unlink($file_delete)

and does not work either.. the file was created by the write_file method of the file helper…

any ideas?

Bye smile

 Signature 

Chile | Debian 2.6.17 | CodeIgniter 1.5.1

 
Posted: 10 September 2007 12:57 AM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2006-12-26
727 posts

Hi latuss,

I think the problem is that unlink(...) does not like directories/paths.

I have vague memories of the same problem and my ‘Kludge’ was to:

1. save the directory where you are - getcwd()
2. change to the directory where the file exists - chdir()
3. unlink(‘the_file’)
4. change back to the original directory.
 
Cheers,

John_Betong
 
 

 Signature 

Joke of the day - Bulletin Board Ideas     (ongoing development site)

My Hippy Trail    Source code   

Latest Project

 
Posted: 10 September 2007 01:59 AM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Avatar
Joined: 2006-10-18
503 posts

I’m pretty sure unlink works ok using full paths.
Check if file_exists and is_writeable to check…

 Signature 

Once in a while I remember I use Twitter