forked from fex-team/ueditor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimageManager.php
More file actions
executable file
·56 lines (53 loc) · 1.73 KB
/
Copy pathimageManager.php
File metadata and controls
executable file
·56 lines (53 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
/**
* Created by JetBrains PhpStorm.
* User: taoqili
* Date: 12-1-16
* Time: 上午11:44
* To change this template use File | Settings | File Templates.
*/
header("Content-Type: text/html; charset=utf-8");
error_reporting( E_ERROR | E_WARNING );
//需要遍历的目录列表,最好使用缩略图地址,否则当网速慢时可能会造成严重的延时
$paths = array('upload/','upload1/');
$action = htmlspecialchars( $_POST[ "action" ] );
if ( $action == "get" ) {
$files = array();
foreach ( $paths as $path){
$tmp = getfiles( $path );
if($tmp){
$files = array_merge($files,$tmp);
}
}
if ( !count($files) ) return;
rsort($files,SORT_STRING);
$str = "";
foreach ( $files as $file ) {
$str .= $file . "ue_separate_ue";
}
echo $str;
}
/**
* 遍历获取目录下的指定类型的文件
* @param $path
* @param array $files
* @return array
*/
function getfiles( $path , &$files = array() )
{
if ( !is_dir( $path ) ) return null;
$handle = opendir( $path );
while ( false !== ( $file = readdir( $handle ) ) ) {
if ( $file != '.' && $file != '..' ) {
$path2 = $path . '/' . $file;
if ( is_dir( $path2 ) ) {
getfiles( $path2 , $files );
} else {
if ( preg_match( "/\.(gif|jpeg|jpg|png|bmp)$/i" , $file ) ) {
$files[] = $path2;
}
}
}
}
return $files;
}