Esempio n. 1
0
/**
 * upload_taoxin_files
 * 上传淘信文件,一次多个
 */
function upload_taoxin_files()
{
    if (empty($_FILES)) {
        return FALSE;
    }
    $year = date("Y");
    $month = date("M");
    $day = date("D");
    $dir = APP_ROOT_PATH . "public/taoxin/";
    $relate_path = "./public/taoxin/";
    // 判断目录是否存在
    mkdir_if_not_exists($dir);
    mkdir_if_not_exists($dir . $year . '/');
    mkdir_if_not_exists($dir . $year . '/' . $month . '/');
    mkdir_if_not_exists($dir . $year . '/' . $month . '/' . $day . '/');
    $last_dir = $dir . $year . '/' . $month . '/' . $day . '/';
    $relate_path = $relate_path . $year . '/' . $month . '/' . $day . '/';
    $error = array();
    $file_link = array();
    foreach ($_FILES['goods_photos']['error'] as $index => $err) {
        // 查看是否有错,有错报错,否则判断类型,再判断大小
        if ($err > 0) {
            // 如果报错了
            if ($err == UPLOAD_ERR_NO_FILE) {
                continue;
            }
            // $error['file'][$index] = upload_taoxin_files($err);
        } else {
            $mime_type = is_img_file($_FILES['goods_photos']['tmp_name'][$index]);
            if (!$mime_type) {
                $error['file'][$index] = '不是图片';
                continue;
            }
            $type = get_img_extension_with_mime($mime_type);
            if ($type === FALSE) {
                $filename = $_FILES['goods_photos']['tmp_name'][$index];
            } else {
                $filename = md5(time() . $_FILES['goods_photos']['tmp_name'][$index]) . $type;
            }
            if (move_uploaded_file($_FILES['goods_photos']['tmp_name'][$index], $last_dir . $filename)) {
                $file_link[] = $relate_path . $filename;
            }
        }
        // end if($err >0)
    }
    // end foreach
    return array('error' => $error, 'file_link' => $file_link);
}
Esempio n. 2
0
<?php

define('SUBBLY_TEST_ENV', TRUE);
function mkdir_if_not_exists($dir)
{
    return is_dir($dir) or mkdir($dir);
}
mkdir_if_not_exists(__DIR__ . '/dummy');
mkdir_if_not_exists(__DIR__ . '/dummy/themes');
mkdir_if_not_exists(__DIR__ . '/dummy/storage');
mkdir_if_not_exists(__DIR__ . '/dummy/storage/cache');
mkdir_if_not_exists(__DIR__ . '/dummy/storage/meta');
mkdir_if_not_exists(__DIR__ . '/dummy/storage/sessions');
$testEnvironment = 'testing';
$config = (require "app/config/{$testEnvironment}/database.php");
extract($config['connections'][$config['default']]);
$connection = new \PDO("{$driver}:host={$host}", $username, $password);
$connection->query("DROP DATABASE IF EXISTS " . $database);
$connection->query("CREATE DATABASE " . $database);
// run migrations for packages
print 'Running migrations' . "\n";
foreach (glob('vendor/*/*', GLOB_ONLYDIR) as $package) {
    $packageName = substr($package, 7);
    // drop "vendor" prefix
    passthru("./bin/artisan migrate --package={$packageName} --env={$testEnvironment} > /dev/null");
    print '.';
}
passthru("./bin/artisan migrate --package=subbly/framework --env={$testEnvironment} > /dev/null");
print '.';
print "\n";
require_once __DIR__ . '/../vendor/autoload.php';