i am trying to delete a physical file (image) from with a folder on the site i used the unlink() function but it does not work can any one help me
Where are you trying to delete the file from? Eg: the file is in
example.com/images/ and you are trying to delete it from
example.com/manager/. PHP is very fussy about file paths, meaning you have to have the exact path to the file. This is an example of unlinking:
/* Image is in example.com/images/ and file is being deleted from example.com */ $dir = __DIR__; // Current Directory $path = '/images/'; // Path from current directory $file = 'myimage.png'; // File to be deleted in the /images/ folder unlink($dir . $path . $file); // Join the current directory, path and file together to make an exact path
This might seem confusing but once you understand it, its quite simple.
This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.