e1seix Posted August 31, 2010 Share Posted August 31, 2010 Bit of a dilemma. Have just figured out the way to work unlink in php to delete images from a directory associated with rows in my sql database. I have ONLY just discovered how to do this though and therefore up until now, when I have deleted a row, the corresponding image has not been deleted from the directory. Not so much of a problem if I didn't have over 3000 images to check. Help me out with correcting this code, please. I know how to link with the directory to display all images one after another. I don't know how to check these files against my database. $mydir = "../imgs/small/"; $d = dir($mydir); while($entry = $d->read()) { if ($entry!= "." && $entry!= "..") { echo "<br><img src=\"/imgs/small/",$entry,"\">"; } } $d->close(); My files are images, formatted like "90_1234567.jpg", where "1234567" is in my database under a column called auto_increment. It's tricky. I know. But I do need this resolved to free up space on my server. Can you help? Quote Link to comment https://forums.phpfreaks.com/topic/212126-tricky-one/ Share on other sites More sharing options...
trq Posted August 31, 2010 Share Posted August 31, 2010 You shouldn't be using the dir function at all, instead, query your database. That is why you have the data stored in the database isn't it? Quote Link to comment https://forums.phpfreaks.com/topic/212126-tricky-one/#findComment-1105435 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.