I am using same syntax as everyone else but... i can't get it to work.
I have tried quite a few options to unlink file from directory.
Summary: delete.php (the file that executes the action) is in the main folder. The file (image) to be deleted is under the sub-directory "upload".
$file = $name . '.' . $ext;
$tmpfile = 'upload/'. $file;
unlink($tmpfile);
Than this one too.
if (!unlink("upload/$file")) {
echo "Error deleting ... $file ... from directory";
}
else {
echo "Deleted $file";
}
And many more. Here is the error log
unlink(upload/Glauber_3232_MAGNOLIA_ST__016.jpg) [function.unlink]: No such file or directory in /home2/braaasil/public_html/openhouse/delete.php on line 30
Therefore, I am not being able to exit the main directory (where delete.php) is and go to subdirectory "upload" where my images are. Any suggestion will be greatly appreciated.
EDIT
public_html
openhouse (sub domain)
delete.php (this is a file)
upload (this is sub folder)
If this is not clear I can take a picture. delete.php and subfolder upload are on the same level, both kids of openhouse. Hope this is clear.
"../upload/$file"?__DIR__ . '/upload/' . $file. Because sometimes the current working dir is not what you think it is.