I have a web application I am writing. I have decided to use sessions to pass variables that call the action in my switch statements on several different pages. On one of my pages, data from a database table is written to a flat file that is created on the server.
I have an include that calls a function to display any files in my directory that the flat files are written to.
I was going to use the following script to give the user a chance to delete the file from the server from the web page.
Here is the function that I am using…
[code=php]
function output(){
$dir = “converted/”;
//Open a known directory, and proceed to read its contents
if(is_dir($dir)){
if($dh=opendir($dir)){
while(($file=readdir($dh))!==false{
if($file!= ‘..’ && !is_dir($dir.$file)){
$file2=str_replace(” “, “%20”,$file);
$arr=explode(“_”,$file);
$tm=$arr[0];
$arr=explode(“.”,$tm);
$tm=$arr[0];
$tm=date(“h.i.s.A”);
$d=date(“m-j-Y”);
$counter=count($file2);
echo”<br><a href=$dir”.$file2.”>$file</a> | Date: $d <a href=export.php?company=delete&f=$dir”.$file2.”>Delete</a>”;
}
}
closedir($dh)
}
}
}
Everything else works accept the delete link…
When they click on the delete it does not change the session variable $_SESSION[‘company’] to “delete”
I need to be able to do this. Can someone either tell me how to do this or tell me a better way to allow a user to delete a file from a directory from the web?
Thanks