Forum Moderators: coopster
$prefix = "http://www.mydomain.com";
$query = "select * from `uploads` where id = " . $id;
// $id is passed to the page via a link
$result = mysql_query($query);
$row = mysql_fetch_array($result);
$i = 0;
$file = fopen($prefix . $row['image'],'w')
or die("Could not open file.");
fclose($file);
if(unlink(($prefix . $row['image']))) $i++;
$file = fopen($prefix . $row['thumb_small'],'w')
or die("could not open file.<br />");
$fclose($file);
if(unlink($prefix . $row['thumb_small'])) $i++;
$file = fopen($prefix . $row['thumb_large'],'w')
or die("could not open file");
$fclose($file);
if(unlink($prefix . $row['thumb_large'])) $i++;
if($i == 2)
{
mysql_free_result($result);
$query = "delete from `uploads` where id = " . $id;
mysql_query($query) or die(mysql_error());
header("Location:edit.php?deleted=$i");
}
else
{
echo (3-$i) . " files were not deleted.";
}
My results are three lines of "Could not delete file" and then "3 files were not deleted". I know I have rwx rights to the files because php wrote the files to the folder in the first place and after storing the files, I call chmod('file', 0777).
Any help is greatly appreciated.