trying to delete a file after it has been read -- my code is as follows:
function ListFiles($dir) {
if($dh = opendir($dir)) {
$files = Array();
$inner_files = Array();
while($file = readdir($dh)) {
if($file != "." && $file != ".." && $file[0] != '.') {
if(is_dir($dir . "/" . $file)) {
$inner_files = ListFiles($dir . "/" . $file);
if(is_array($inner_files)) $files = array_merge($files, $inner_files);
} else {
array_push($files, $dir . "/" . $file);
}
}
}
closedir($dh);
return $files;
}
}
then it does all the display..
followed by:
if ($recipe_title =="" || $ingredients =="" || $instructions =="")
{
echo "error with file, saving file for later";
}
else
{
$sql="Insert into sbrecipe_recipes (sb_title,sbuser_id,sb_ingredient,sb_recipetext,sb_posted_on,sb_hits,sb_website,sbscore,sbno_of_ratings,sb_dish_type)";
$sql.="values ('$recipe_title','$author','$ingredients', '$instructions', '$recipe_date','$hits','$website','$rating','$total_rates','$recipe_cat_id')";
unlink ('$file');
if (!unlink($file))
{
echo ("Error deleting $file");
exit;
}
else
{
echo "File successfully entered, file removed";
}
}
echo "$counter records added";
$counter = $counter + 1;
if (!mysql_query($sql,$connect))
{
die('Error: ' . mysql_error());
}
}
keeps crapping out and won't delete file
any thoughts?