Posted By

onefastsnail on 05/24/12


Tagged


Versions (?)

list images


 / Published in: PHP
 

  1. <!DOCTYPE html>
  2. <html lang="en">
  3.  
  4. <head>
  5.  
  6. <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  7. <meta name="robots" content="all, index, follow" />
  8. <meta name="description" content="" />
  9. <meta name="keywords" content="" />
  10. <meta name="author" content="" />
  11. <title>Images</title>
  12. <link rel="shortcut icon" href="#" />
  13.  
  14. </head>
  15.  
  16. <body>
  17.  
  18. <div id="wrap" class="clearfix">
  19.  
  20. <?
  21. if(isset($_REQUEST["option"])){
  22. if(file_exists($_REQUEST["f"])){
  23. unlink($_REQUEST["f"]);
  24. }
  25. }
  26.  
  27. //path to directory to scan
  28. $directory = "";
  29.  
  30. //get all image files with a .jpg extension.
  31. $images = glob("" . $directory . "{*.jpg,*.gif,*.png}", GLOB_BRACE);
  32.  
  33. //print each file name
  34.  
  35. ?>
  36.  
  37. <? foreach($images as $image){ ?>
  38. <div style="width:100px; float:left; margin:20px; margin-bottom:50px; font-size:11px; font-family:arial; text-align:center;">
  39. <div style="width:100px; height:150px; overflow:hidden;"><a href="<?=$image;?>" target="_blank"><img src="<?=$image;?>" alt="" width="100"/></a></div>
  40. <p><?=$image;?></p>
  41. <p><?=ceil(filesize($image)/1024);?>kb</p>
  42. <p><a href="<?=$_SERVER['PHP_SELF'];?>?option=delete&amp;f=<?=$image;?>" class="delete" title="Are you sure you want to delete <?=$image;?>">Delete?</a></p>
  43. </div>
  44. <? } ?>
  45.  
  46. </div><!-- end of wrap -->
  47.  
  48. <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
  49. <script>
  50. $(".delete").click(function() {
  51. return window.confirm(this.title || 'Delete this record?');
  52. });
  53. </script>
  54.  
  55. </body>
  56.  
  57. </html>

Report this snippet  

You need to login to post a comment.