Hi,
I'm fairly new to the php thing so bear with me.
I've upload an image to a folder on my hosts server and also written the file name to a database in the process. I also have created a page where I can delete the database entry. I am trying to delete the file from the server on this page also, from the same button, i.e. on click kills DB entry and file at the same time.
The databse part deletion is complete but I am stuck on the file deletion.
The code looks something like this
$tempFolder = main_photos;
(main_photos is the name of the folder where I am storing the images)
$tempFile = $row_rs_main_photo['main_photo_filename']);
(the database entry which stores the filename)
$tempPath = $tempFolder."/".$tempFile;
(concat' folder and filename for file path)
if(isset( $Submit )) {
unlink ("$tempPath");
}
(the file deletion bit using PHP's unlink() function)
This does not work.
If I replace the database entry with a hardcoded filename of a file I know I want to delete it works and deletes the file!
Is the problem something to do with the formating on the retreived filename from the database?
Or is it possible that the database record is deleted before the value can be reteievd to delete the image?
I'm well stuck.
Any help on this one would be much appreciated
binaryjunk
UK😕 😕