/* delete not working */ // You missed the brackets for the function function unlink { if($_GET['action'] && $_GET['action'] == 'delete') { unlink($_GET['.$file']); header("$path."/".$file"); exit(); } }
I have to say that code is incredibly weird (to me at least).
- Your unlink function doesn't look like a function. And if it was a function you should be calling it. Else it would be useless to create a function. - In your while loop you have ifs in ifs in ifs. You could just combine them all with && instead. - Also in your while loop you have
if($file != "$file.avi" && $file!= "$file.srt")
This will always return true. - In your echo, you're closing an anchor link without starting one. Doesn't make sense to me.
Anyway, I think this is what your code should look like:
//define the path as relative $path = "../uploads";
/* delete not working */ if(array_key_exists('action', $_GET) && $_GET['action'] == 'delete' && array_key_exists('filename', $_GET)) { $file = $_GET['filename']; unlink($path.'/'.$file);
/* This doesn't make sense to me at all. Why would you TRY to redirect to a file you just deleted? (Notice I'm saying 'TRY' because you aren't redirecting but I guess that's what you were trying. */ //header("$path."/".$file"); //exit();
// Redirecting to this file to clear out the params in the url. die(header("Location: $thisFile")); }
//using the opendir function $dir_handle = @opendir($path) or die("Unable to open $path");
if you can shade some light on what is the error and format your code and post it i guess i can figure out.
from what you have said issue could be...
issue could be path issue.
or
issue could be because of folder rights if you are on windows server
- Your unlink function doesn't look like a function. And if it was a function you should be calling it. Else it would be useless to create a function.
- In your while loop you have ifs in ifs in ifs. You could just combine them all with && instead.
- Also in your while loop you have
This will always return true.
- In your echo, you're closing an anchor link without starting one. Doesn't make sense to me.
Anyway, I think this is what your code should look like: