imageManager.php 992 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. /**
  3. * Created by JetBrains PhpStorm.
  4. * User: ueditor
  5. * Date: 12-1-16
  6. * Time: 上午11:44
  7. * To change this template use File | Settings | File Templates.
  8. */
  9. error_reporting(E_ERROR|E_WARNING);
  10. $path = 'upload'; //最好使用缩略图地址,否则当网速慢时可能会造成严重的延时
  11. $action = htmlspecialchars($_POST["action"]);
  12. if($action=="get"){
  13. $files = getfiles($path);
  14. if(!$files)return;
  15. $str = "";
  16. foreach ($files as $file) {
  17. $str .= $file."ue_separate_ue";
  18. }
  19. echo $str;
  20. }
  21. function getfiles($path, &$files = array()){
  22. if (!is_dir($path)) return;
  23. $handle = opendir($path);
  24. while (false !== ($file = readdir($handle))) {
  25. if ($file != '.' && $file != '..') {
  26. $path2 = $path . '/' . $file;
  27. if (is_dir($path2)) {
  28. getfiles($path2, $files);
  29. } else {
  30. if (preg_match("/\.(gif|jpeg|jpg|png|bmp)$/i", $file)) {
  31. $files[] = $path2;
  32. }
  33. }
  34. }
  35. }
  36. return $files;
  37. }
  38. ?>