Delete files via webpage

May 7, 2010 at 09:23:32
Specs: Windows 7
Here is what I am looking at. We have an engineer taking pictures at an interval of about 1 or 2 per minute. The pictures are stored on a local computer, which I am going to also be serving that directory locally as a webpage. What I am looking to do, is have a webpage showing the last 8 pictures taken (real-time) and allow the engineer to delete the bad photos just by clicking on them. I have seen this before, buut I can't find good code for it anywhere. The language doesn't much matter to me be it PHP, html, asp, or flash. Does anyone have any good examples or any help they could give?


See More: Delete files via webpage

Report •

May 7, 2010 at 14:03:52
With php, a simple idea might be something like using filemtime to get the file's modified time and arsort to get the most recent 8 files.

No idea on whether or not it's good; likewise, not really tested in depth or secure, but maybe something like...


   if(isset($_GET["del"])) {

      $file = urldecode($_GET["del"]);
      if(file_exists($file)) { unlink($file); }


   $arr = null;

   foreach(glob("*.img_type") as $fn) {

      if(file_exists($fn)) { 
         $arr[$fn] = filemtime($fn); 

   $limit = 0;

   foreach($arr as $file_name => $mod_time) {

      if($limit < (count($arr) > 8 ? 8 : count($arr))) {

         echo "<a href='" . 
              $_SERVER["PHP_SELF"] .
              "?del=" .
              urlencode($file_name) .
              "'><img src='" . $file_name . "'></a> ";


Hope at least it may provide an idea to try.

Report •
Related Solutions

Ask Question