示例#1
0
            if ($ext == "png") {
                return true;
            } else {
                if ($ext == "bmp") {
                    return true;
                } else {
                    return false;
                }
            }
        }
    }
}
$dir_contents = scandir($dir);
foreach ($dir_contents as $item) {
    if (is_dir($dir . $item) && $item != '.' && $item != '..') {
        $dirs[] = $item;
    }
}
foreach ($dirs as $current) {
    $dir_contents = scandir("./images/" . $current . "/");
    foreach ($dir_contents as $item) {
        if ($item != '.' && $item != '..' && !is_dir($dir . $item) && is_valid_extension($item) && !file_exists("./thumbnails/{$current}/thumbnail_{$item}")) {
            $image = new image();
            if (!is_dir("./thumbnails/" . $current . "/")) {
                $image->makethumbnailfolder($current);
            }
            $image->thumbnail($current . "/" . $item);
            print "./thumbnails/" . $current . "/thumbnail_" . $item . "<br>\n";
        }
    }
}
示例#2
0
$php_upload_errors = array(0 => 'There is no error, the file uploaded with success', 1 => 'The uploaded file exceeds the upload_max_filesize directive in php.ini', 2 => 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form', 3 => 'The uploaded file was only partially uploaded', 4 => 'No file was uploaded', 6 => 'Missing a temporary folder', 7 => 'Failed to write file to disk.', 8 => 'A PHP extension stopped the file upload.');
if (isset($_POST['submit_image'])) {
    // make sure uploaded file is valid and not empty
    if (!$_FILES['file_upload'] || empty($_FILES['file_upload']) || !is_array($_FILES['file_upload'])) {
        $photo_errors[] = "No file was uploaded";
    } elseif (!valid_photo_filename($_FILES['file_upload']['name'])) {
        $photo_errors[] = "Invalid characters in file name. Only characters, numbers and (_-.) allowed.";
        $image_name = "";
    } elseif ($_FILES['file_upload']['error'] != 0) {
        foreach ($php_upload_errors as $key => $value) {
            if ($_FILES['file_upload']['error'] == $key) {
                $photo_errors[] = $value;
                $image_name = "";
            }
        }
    } elseif (!is_valid_extension($_FILES['file_upload']['name'])) {
        $photo_errors[] = "Files must be of either type jpeg, jpg, jpe, gif or png.";
        $image_name = "";
    } else {
        // target directory of file system
        $target_dir = SITE_ROOT . DS . "uploaded_images";
        // specify attribute variables
        $user_id = $_GET['id'];
        $filename = uniqid('', true);
        // creates unique id
        $type = str_replace('image/', '.', $_FILES['file_upload']['type']);
        $size = $_FILES['file_upload']['size'];
        $tmp_name = $_FILES['file_upload']['tmp_name'];
        // check if an image already exists
        $sql = "SELECT * FROM user_photo WHERE id = {$user_id}";
        $result = $db->query($sql);
示例#3
0
{
    $ext = explode('.', $img);
    $ext = array_pop($ext);
    switch ($ext) {
        case 'jpg':
        case 'jpeg':
        case 'webm':
        case 'png':
        case 'gif':
            return true;
        default:
            return false;
    }
}
$dir_contents = scandir($dir);
foreach ($dir_contents as $current) {
    if (!is_dir($dir . $current) || $current == '.' || $current == '..') {
        continue;
    }
    $dir_contents = scandir("./images/" . $current . "/");
    if (!is_dir("./thumbnails/" . $current . "/")) {
        $image->makethumbnailfolder($current);
    }
    foreach ($dir_contents as $item) {
        $thumb = "./thumbnails" . $misc->getThumb($item, $current);
        if ($item != '.' && $item != '..' && !is_dir($dir . $item) && is_valid_extension($item) && !file_exists($thumb)) {
            $image->thumbnail($current . "/" . $item);
            print $thumb . "<br>";
        }
    }
}