1 | <?php |
---|
2 | $racine='../../../../'; |
---|
3 | $racine_up='../../../.'; |
---|
4 | if(isset($_GET['root'])){ |
---|
5 | $root= $racine_up.$_GET['root'] ; |
---|
6 | $root_img= $racine_up.$_GET['root_img'] ; |
---|
7 | $root_theme= $racine_up.$_GET['root_theme'] ; |
---|
8 | } |
---|
9 | |
---|
10 | |
---|
11 | define ('PHPWG_ROOT_PATH',$root); |
---|
12 | define ('PHPWG_THEMES_PATH',PHPWG_ROOT_PATH."themes/" ); |
---|
13 | define ('PHPWG_THEME_PATH', $root_theme ); |
---|
14 | |
---|
15 | |
---|
16 | include("ImgLoad.php"); |
---|
17 | /************************************************************* |
---|
18 | * server destDir - location where image will be uploaded |
---|
19 | * upload_url - http address to access image |
---|
20 | * max_size - Maximum size for image or file type |
---|
21 | * file_support - Supported file type |
---|
22 | * thumbnail_dir - Location of thumbnail on server |
---|
23 | * thumbnail_dimension - dimension of thumbnail to displayed |
---|
24 | * callback - when image is created/uploaded on server , this function is called to store information in database or anything eg. add_userEntry |
---|
25 | * loadcallback - this function is called to retrive details of all images stored so far on *server eg. getalldetails |
---|
26 | ***************************************************************/ |
---|
27 | |
---|
28 | |
---|
29 | /* configuration options */ |
---|
30 | $options = array(); |
---|
31 | $options = array( 'rootImg' => $root_img, |
---|
32 | 'destDir'=>$root_img, |
---|
33 | 'upload_url'=>$root_img, |
---|
34 | 'max_size'=>array( |
---|
35 | 'jpeg'=>'20111110', |
---|
36 | 'jpg'=>'2011110', |
---|
37 | 'gif'=>'2011110', |
---|
38 | 'png'=>'2011110', |
---|
39 | 'bmp'=>'2011110', |
---|
40 | 'txt'=>'500' |
---|
41 | ), |
---|
42 | |
---|
43 | 'file_support'=>array('jpeg', 'jpg', 'png', 'gif','bmp' ), |
---|
44 | |
---|
45 | 'thumbnail_dir'=>$root_img , |
---|
46 | 'thumbnail_url'=>$root_img , |
---|
47 | 'thumbnail_dimension'=>array("max_width"=>940,"max_height"=>200) |
---|
48 | |
---|
49 | ); |
---|
50 | |
---|
51 | // $options['callback'] = 'add_userEntry'; |
---|
52 | // $options['loadcallback'] = 'getalldetails'; |
---|
53 | $options['loadcallback'] = 'get_list_images'; |
---|
54 | |
---|
55 | $options['root'] = '.'; |
---|
56 | $userid = 5; |
---|
57 | $action = $_REQUEST['action']; |
---|
58 | |
---|
59 | $Filehandler = new AjaxImgupload($options); |
---|
60 | $Filehandler->responder($action); |
---|
61 | |
---|
62 | |
---|
63 | |
---|
64 | function get_list_images($obj){ |
---|
65 | |
---|
66 | $path_img=$obj->options['destDir'] ; |
---|
67 | $path= $path_img; |
---|
68 | if (is_dir($path)) { |
---|
69 | |
---|
70 | $fh = opendir($path); |
---|
71 | $details = array(); |
---|
72 | $details['files'] = array(); |
---|
73 | while ($file = readdir($fh)){ |
---|
74 | $pathfile = $path . $file; |
---|
75 | if ($file != '.' and $file != '..' and $file != '.svn' and !is_dir($pathfile)){ |
---|
76 | $details['files'][] = array( |
---|
77 | "name"=>$file, |
---|
78 | "upload_name"=>$file, |
---|
79 | 'thumbimgurl'=>$pathfile, |
---|
80 | 'action'=>'loaded', |
---|
81 | 'imgUrl'=>$path_img.$file, |
---|
82 | ); |
---|
83 | } |
---|
84 | } |
---|
85 | closedir($fh); |
---|
86 | } else{ |
---|
87 | |
---|
88 | echo realpath("."); |
---|
89 | echo "Erreur dir: " . $path ; |
---|
90 | |
---|
91 | } |
---|
92 | return $details; |
---|
93 | } |
---|
94 | |
---|
95 | ?> |
---|