Exemple #1
0
<?php

require 'reader.php';
require '../include/connection.php';
require "../include/upload_dir.php";
require "../include/func.php";
mkFile($excel_upload);
if ($_FILES["filename"]["name"]) {
    $excel_name = basename($_FILES["filename"]["name"]);
    $excel_extension = pathinfo($excel_name, PATHINFO_EXTENSION);
    $timestamp = getMilliSecond();
    $excel_new_name = $timestamp . "SL." . $excel_extension;
    $excel_url = $excel_upload . $excel_new_name;
    move_uploaded_file($_FILES["filename"]["tmp_name"], $excel_url);
} else {
    echo 0;
}
$data = new Spreadsheet_Excel_Reader();
$data->setOutputEncoding('gbk');
$data->read($excel_new_name);
error_reporting(E_ALL ^ E_NOTICE);
for ($i = 1; $i <= $data->sheets[0]['numRows']; $i++) {
    $sql2 = "select * from school_list where cid='" . $data->sheets[0]['cells'][$i][2] . "' and school like '" . $data->sheets[0]['cells'][$i][4] . "'";
    $rs = $db->query($sql2);
    $rs_arr = $rs->fetchAll(PDO::FETCH_ASSOC);
    if (count($rs_arr) == 0) {
        $sql = "INSERT INTO school_list(sid,cid,zid,school,school_type) VALUES('" . $data->sheets[0]['cells'][$i][1] . "','" . $data->sheets[0]['cells'][$i][2] . "','" . $data->sheets[0]['cells'][$i][3] . "','" . $data->sheets[0]['cells'][$i][4] . "','" . $data->sheets[0]['cells'][$i][5] . "\n')";
        $db->exec($sql);
        for ($j = 1; $j <= $data->sheets[0]['numCols']; $j++) {
            echo "\"" . $data->sheets[0]['cells'][$i][$j] . "\",";
        }
<?php

require "../include/upload_dir.php";
require "../include/func.php";
mkFile($post_upload);
if ($_FILES["filename"]["name"]) {
    $img_name = basename($_FILES["filename"]["name"]);
    $img_extension = pathinfo($img_name, PATHINFO_EXTENSION);
    $timestamp = getMilliSecond();
    $post_new_name = $timestamp . "P." . $img_extension;
    $post_url = $post_upload . $post_new_name;
    move_uploaded_file($_FILES["filename"]["tmp_name"], $post_url);
    echo $post_new_name;
} else {
    echo json_encode(0);
}
<?php

require "../include/upload_dir.php";
require "../include/func.php";
mkFile($avatar_upload);
if ($_FILES["filename"]["name"]) {
    $avatar_name = basename($_FILES["filename"]["name"]);
    $avatar_extension = pathinfo($avatar_name, PATHINFO_EXTENSION);
    $times = getMilliSecond();
    $avatar_new_name = $times . "A." . $avatar_extension;
    var_dump($avatar_new_name);
    $avatar_url = $avatar_upload . $avatar_new_name;
    move_uploaded_file($_FILES["filename"]["tmp_name"], $avatar_url);
    echo $avatar_new_name;
} else {
    echo json_encode(0);
}