Hi I am having some problems getting a file deleted from my server,
The way it works is: The file name/ID is stored in the mysql database, and the ACTUAL file is stored on the server - pretty standard stuff.
Im using the unlink() funtion to remove the file from the server, but I get a Warning: unlink(photo_brent.jpg) [function.unlink]: No such file or directory in /home/pedpower/public_html/deletepic.php on line 40
error msg, here is my code.
$query = "select * from image_gallery where id ='$deleteinput'";
$result = mysql_query($query, $connection);
while($myrow = mysql_fetch_array($result))
{
$id = $myrow["id"];
$tpicimage = $myrow["image"];
}
$tfiledir = "images/upload/$tpicimage";
//echo "$tfiledir";
unlink(trim($tpicimage));
//deletes the information from the database
$query = "delete from image_gallery where id = '$deleteinput'";
//assigns the results of the query to a variable
$result = mysql_query($query, $connection);
The file DOES exist (in both DB and Server).
Line 40 = unlink(trim($tpicimage));
Any ideas?
Thanks