Jump to content

delete images..


techker

Recommended Posts

hey guys i have a script that inserts info in a mysql database and moves an image to a directory and inserting the path in the db.(instead of using the database to store images)

 

no the problem is that when you delete the query it does not delete the pic.so he is going to have a nasty accumulation of images after a couple of years..lol

 

so i was wondering if somebody can tel me how or point me in the right direction to haw to make a script that will show the images in a directory and you can delete the unwanted pic..

Link to comment
Share on other sites

i got this that views the directory and lists the images name.now the only thing i need to know is to link the name to a delete file that hase the unlink function

 

<?php

$imgdir = './'; // the directory, where your images are stored
$allowed_types = array('png','jpg','jpeg','gif'); // list of filetypes you want to show

$dimg = opendir($imgdir);
while($imgfile = readdir($dimg))
{
  if(in_array(strtolower(substr($imgfile,-3)),$allowed_types))
  {
   $a_img[] = $imgfile;
   sort($a_img);
   reset ($a_img);
  } 
}

$totimg = count($a_img); // total image number
  
for($x=0; $x < $totimg; $x++)
{
  $size = getimagesize($imgdir.'/'.$a_img[$x]);

  // do whatever
  $halfwidth = ceil($size[0]/2);
  $halfheight = ceil($size[1]/2);
  echo 'name: '.$a_img[$x].' width: '.$size[0].' height: '.$size[1].'<br />';
}

?>

 

i need the link to echo the name of the file to delete.for the unlink to work

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.