Member Avatar

Hi All, I'm trying to unlink a file. I start with a form and submit it using javascript's submit() (out of necessity). Eventually the php code arrives at a function and unlinks the file (or rather doesn't). Now, the files unlinks when I use die() to exit out of script at the end of the function when testing but when I run it normally, nothing gets unlinked and the file remains. The code reaches the unlink() function either way. Is this a javascript problem or php issue? Thanks for any help offered.

Member Avatar
0
38
Member Avatar

I have three files which when i click on delete should be removed. How am I able to use the unlink and realpath for my multiple files? public function delete() { $path_to_file = FCPATH . 'application/modules/admin/controllers/module' .'/'. $this->uri->segment(5).'.php'; $path_to_file_lang = FCPATH . 'application/modules/admin/language'.'/' .'english' .'/'. 'module/'. $this->uri->segment(5).'lang.php'; $path_to_file_view = FCPATH . 'application/modules/admin/views/template/module' .'/'. $this->uri->segment(5).'.tpl'; if (unlink(realpath($path_to_file), realpath($path_to_file_lang)) ) { echo "deleted" .' '. $path_to_file; echo "<br/>"; echo "deleted" .' '. $path_to_file_lang; echo "<br/>"; echo "deleted" .' '. $path_to_file_view; } else { echo "did not delete"; } }

Member Avatar
0
24
Member Avatar

Hi! I have a problem with the unlink() php function. What I try to do is to delete a certain file in a directory. Now the function works fine. But when I call it then it deletes ALL the files inside of that directory. What I want is for it to delete that certain file which the user can select from a list. I display all the files with php and beside it is a 'X' ahref link which doesn't seem to be identified with that file next to it. This 'X' is used to delete the file. echo "$file …

Member Avatar
0
16
Member Avatar

Hi I want users to be able to upload new images that overwrite old images but I am struggling. The original upload and naming works fine but I want any new images to have the same name, so I unlink the original before uploading the new image, is this the correct way to do it? If it is then I am doing something wrong as it does not put the new image in. I think it may be something to do with unlinking, I don't really get how to do it, the file $new_file_name is in /upload/ and here is …

Member Avatar
0
7
Member Avatar

I'm working on a task for a client that I thought would be simple. A remote computer uploads a file upon some event. My site needs to display a flag/statement if that file exists. So, upon page load it checks if the file exists. That all works fine and dandy. The problem is that the user wants to have a reset button. In other words, after he sees that the flag is set, he wants to be able to click a button or text link and delete that file. I want to use something like this. [CODE] <?php if (file_exists($triggerfile)) …

Member Avatar
0
7
Member Avatar

Hi all, Once again I am here with a simple problem which is hard enough to solve by myself: I got the following keys in an array: [CODE] 20110225104849 20110225104833 20110225104848 [/CODE] And following files in a folder: [CODE] google_20110225091600.7z google_20110225091622.7z google_20110225100306.7z google_20110225100410.7z google_20110225104833.7z google_ready_20110225100410.txt google_ready_20110225104833.txt Yahoo_20110225091639.7z Yahoo_20110225100320.7z Yahoo_20110225100424.7z Yahoo_20110225104849.7z Yahoo_ready_20110225100424.txt Yahoo_ready_20110225104849.txt Community_20110225091637.7z Community_20110225100318.7z Community_20110225100422.7z Community_20110225104848.7z Community_ready_20110225100422.txt Community_ready_20110225104848.txt [/CODE] I should unlink/delete all the files from the folder except those which is/are carrying the keys in the filename. Can I use a for loop? for match and delete? Or any handy shortcut?

Member Avatar
0
7

The End.