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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.