-
You can't delete the containing folder but why not a parallel file like:
dir/subdir2/example.php from dir/subdir1/del.php-- path: ../subdir2/example.php
similar to dir/ex2.php using ../ex2.php
I have never had the need to try it though. You could easily do it with an include, regardless.
-
I don't understand... But say this is your root folder layout:
http://localhostr.com/files/18826c/capture.png
Within includes/unlinkthis.php, you could not do:
PHP Code:
unlink("../examples/file.php");
-
can someone show me how to create form where you can choose in RADIO style.
Also it has two buttons and one value to send - ID.
One button deletes existing file, other renames it to good.png
but everythin in one form. Also some php before header I think :D thanks
-
PHP Code:
<?php
function get_files(){
$files = glob("*");
$radio = array();
foreach($files as $key => $value){
if(is_dir($files[$key])){
unset($files[$key]);
continue; //thanks to techietim
}
$radio[] = '<input type="radio" name="delete" id="'.$key.'" value="'.$value.'" /><label for="'.$key.'">'.$value.'</label><br />';
}
return implode($radio);
}
if(isset($_POST['submit'])){
unlink($_POST['delete']);
}
if(isset($_POST['rename'])){
rename($_POST['delete'], "good.png");
}
?>
<form action="" method="post">
<?php
echo get_files();
?>
<input type="submit" name="submit" value="Submit"/>
<input type="submit" name="rename" value="Rename"/>
</form>
-
ok, looks great... Can you explain how it works? I dont understand the function thing... (also, why you use global?)
-
It's glob(). It gets all the files in the directory.
The first function of the code gets all the files, and displays them in radios.
And the next part renames/unlinks.
-
How'd it work out for you?
-
I am really sorry Nile, that I haven't seen your last posts... I was working on something else...
So, it works great :D
But one more question. I have mysql information of file:
$name
$directory
$username - who uploaded.
How I can let to see only those files to owners, which only they uploaded.
I don't want that everyone could delete all files...