示例#1
0
文件: save.php 项目: GameHomePC/surf3
    $path = $fileDir . $upload;
    function countFile($dir)
    {
        $num = 0;
        if (is_dir($dir)) {
            if ($open = opendir($dir)) {
                while (($read = readdir($open)) !== false) {
                    if ($read == '.' || $read == '..') {
                        continue;
                    }
                    if (!is_dir($dir . '/' . $read)) {
                        $num += 1;
                    }
                }
            }
        }
        return $num;
    }
    if (!is_dir($path)) {
        mkdir($path, 0777);
    }
    $time = time();
    $count = countFile($path);
    $fileName = $time . '_' . $count . '.jpg';
    $filePath = $path . '/' . $fileName;
    $im = $GLOBALS["HTTP_RAW_POST_DATA"];
    $fp = fopen($filePath, 'wb');
    fwrite($fp, $im);
    fclose($fp);
    echo "filename=" . $fileName . "&base=" . $_SERVER["HTTP_HOST"] . dirname($_SERVER["PHP_SELF"]) . $upload . '/';
}
示例#2
0
<?php

$input_id = $_POST[id];
$input_year = $_POST[year];
$json = array('data' => countFile($input_id, $input_year));
$json_en = json_encode($json);
echo $json_en;
function countFile($id, $year)
{
    $db_host = "127.0.0.1";
    $db_user = "******";
    $db_pass = "******";
    $db_select = "PSMS";
    $db_connect = "mysql:host=" . $db_host . ";dbname=" . $db_select;
    $db_go = new PDO($db_connect, $db_user, $db_pass);
    $db_go->exec("SET NAMES UTF8");
    $sql = $db_go->prepare("SELECT month, COUNT(path) AS count\n\t\t\t\t\t\t\t  FROM payroll \n\t\t\t\t\t\t\t  WHERE user_id = :id AND year = :year \n\t\t\t\t\t\t\t  GROUP BY month");
    $sql->bindParam(":id", $id, PDO::PARAM_STR, 10);
    $sql->bindParam(":year", $year, PDO::PARAM_INT, 4);
    $sql->execute();
    $result = $sql->fetchAll();
    return $result;
}