示例#1
0
$path = $_GET['dir_path'];
$files = FileGetter::listFolderContents($path);
$list = "";
$img_exts = $GLOBALS["upload_vars"]["allowed_image_extensions"];
$audio_exts = $GLOBALS["upload_vars"]["allowed_audio_extensions"];
$return_info = array();
for ($i = 0; $i < count($files); $i++) {
    $item = $files[$i];
    if (isset($item['folder'])) {
        $dir_path = $path . "/" . $item['folder'];
        $data = FileGetter::getDirectoryInfo($dir_path);
        array_push($return_info, $data);
    }
    if (isset($item['file'])) {
        $file_path = $GLOBALS['index_path'] . $path . "/" . $item['file'];
        $extension = pathinfo($file_path, PATHINFO_EXTENSION);
        $server_path = $path . "/" . $item['file'];
        $resource_path = $GLOBALS['base_url'] . $server_path;
        if (in_array($extension, $img_exts)) {
            $data = FileGetter::getResourceInfo("image", $resource_path, $server_path, $item['file']);
            array_push($return_info, $data);
        }
        if (in_array($extension, $audio_exts)) {
            $data = FileGetter::getResourceInfo("audio", $resource_path, $server_path, $item['file']);
            array_push($return_info, $data);
        }
    }
}
header('Content-Type: application/json; charset=utf-8');
echo json_encode($return_info);
示例#2
0
        $is_img = in_array($extension, $upload_vars["allowed_image_extensions"]) ? true : false;
        $max_kbs = $is_img ? $upload_vars["max_kb_img_upload"] : $upload_vars["max_mb_audio_upload"] * 1000;
        $to_big = (int) $upload_kbs >= $max_kbs ? true : false;
        if (!$to_big) {
            //conversion bytes to KB
            if (!file_exists($GLOBALS['index_path'] . $folder_path . "/" . $upload["name"])) {
                move_uploaded_file($upload["tmp_name"], $GLOBALS['index_path'] . $folder_path . "/" . $upload["name"]);
                $result = "File Up Loaded";
                $success = true;
                //$file_icon="<img src='".$GLOBALS['base_url']."/style/resources/images.png'  data-filepath='".$GLOBALS['base_url'].$folder_path."/".$upload["name"]."' class='icon' onclick='selectFolderList(this)' />";
                $server_path = $folder_path . "/" . $upload["name"];
                $url_path = $GLOBALS['base_url'] . $server_path;
                if ($is_img) {
                    $li_data = FileGetter::getResourceInfo("image", $url_path, $server_path, $upload["name"]);
                } else {
                    $li_data = FileGetter::getResourceInfo("audio", $url_path, $server_path, $upload["name"]);
                }
                $data = $li_data;
            } else {
                $result = "File Already Exists In This Folder";
            }
        } else {
            $result = "File To Large over " . $max_kbs . " KB";
        }
    } else {
        $result = "File Type " . $type . " Not Allowed";
    }
} else {
    $result = "upload error";
}
?>