Jump to content

Tricky One


e1seix

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/212126-tricky-one/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.