Esempio n. 1
0
     // $name=implode(".",$filename);
     $name = $_FILES['file']['name'];
     //$name=iconv("GBK","UTF-8",$name);
     //$name1=$name.".Mcncc";
     $uploadfile = $realAdminPath . $uploaddir . $_POST['imgCat'] . "/" . $name;
     $databaseURL = $uploaddir . $_POST['imgCat'] . "/" . $name;
     $disFile = $virtualAdminPath . "res/images/" . $_POST['imgCat'] . "/" . $name;
     //var_dump(file_exists($uploadfile));
 } while (file_exists($uploadfile));
 //echo "uploadFile:".$uploadfile;
 //echo "databaseURL:".$databaseURL;
 //echo "disFile".$disFile;
 if (move_uploaded_file($_FILES['file']['tmp_name'], $uploadfile)) {
     $array = array("option" => "create", "imgName" => $_FILES['file']['name'], "URL" => $_POST['pLink'], "size" => $_FILES['file']['size'], "imgCat" => $_POST['imgCat'], "createTime" => date("Y-m-d H:i:s"), "updateTime" => date("Y-m-d H:i:s"), "status" => "Y");
     //var_dump($array);
     $result = saveDatabase($array);
     //var_dump($result);
     //echo trim($result);
     //if(!(trim($result)=="success!")){
     //die("数据库操作失败!");
     //}
     /*echo "tmp_dir:".$_FILES['file']['tmp_name']."<br/>";  
     		echo "判断is_uploaded_file:".var_dump(is_uploaded_file($_FILES['file']['tmp_name']))."<br/>";
     		echo "error:".$_FILES["file"]['error']."<br/>";*/
     //if(is_uploaded_file($_FILES['file']['tmp_name'])){
     //echo "uploadFile:".$uploadfile;
     //输出图片预览
     //echo "<center>您的文件已经上传完毕 上传图片预览: </center><br><center><img src='$disFile'></center>";
     //echo"<br><center><a href='javascript:history.go(-1)'>继续上传</a></center>";
     echo "<script type='text/javascript'>window.location.href='/htdocs/admin/index.php?href=home/index.php';</script>";
     //echo"<br><center><a href='index.php'>继续上传</a></center>";
    $row = 1;
    $d = array();
    if (($handle = fopen($db_file, "r")) !== FALSE) {
        while (($data = fgetcsv($handle, 100000, ",")) !== FALSE) {
            $num = count($data);
            $row++;
            $vals = array();
            for ($c = 0; $c < $num; $c++) {
                $vals[$c] = $data[$c];
            }
            $d[$row] = $vals;
        }
        fclose($handle);
    }
    return $d;
}
function saveDatabase($data, $filename)
{
    $fp = fopen($filename, 'w');
    if ($fp == FALSE) {
        return;
    }
    foreach ($data as $d) {
        fputcsv($fp, $d);
    }
    fclose($fp);
}
$d = loadDatabase("dbfile.txt");
$d[] = array("lat" => $lat, "lng" => $lng, "zoom" => $zoom, "filename" => $filename);
saveDatabase($d, "dbfile.txt");
return;
<?php
  require_once('databaseUtil.php');
  saveDatabase();
?>