コード例 #1
0
ファイル: upload.php プロジェクト: fannil/ptutS3-4
<?php

include "db.php";
$ds = DIRECTORY_SEPARATOR;
$subFolder = getCookieId();
$storeFolder = "dptImg/" . $subFolder;
if (!empty($_FILES)) {
    $tempFile = $_FILES['file']['tmp_name'];
    $targetPath = dirname(__FILE__) . $ds . $storeFolder . $ds;
    $targetFile = $targetPath . $_FILES['file']['name'];
    addImg($_FILES['file']['name'], $subFolder);
    move_uploaded_file($tempFile, $targetFile);
} else {
    $result = array();
    $files = scandir($storeFolder);
    if (false !== $files) {
        foreach ($files as $file) {
            if ('.' != $file && '..' != $file) {
                $obj['name'] = $file;
                $obj['size'] = filesize($storeFolder . $ds . $file);
                $result[] = $obj;
            }
        }
    }
    header('Content-type: text/json');
    header('Content-type: application/json');
    echo json_encode($result);
}
コード例 #2
0
 public function updateImg()
 {
     $img = M('img');
     $types = array('pageBg' => array('festival', 'scenery'), 'images' => array('festival', 'scenery'), 'music' => array('exciting', 'popular', 'warm'));
     addImg($types);
     $list = $img->where('id>0')->field('img_url, img_size, img_type')->select();
     $this->assign('list', $list);
     $this->display();
 }