コード例 #1
0
ファイル: imgboard.php プロジェクト: GlazzzN/TinyIB
     }
     $thumb_location = "thumb/" . $post['thumb'];
     list($thumb_maxwidth, $thumb_maxheight) = thumbnailDimensions($post);
     if (!createThumbnail($file_location, $thumb_location, $thumb_maxwidth, $thumb_maxheight)) {
         fancyDie("Could not create thumbnail.");
     }
     addVideoOverlay($thumb_location);
     $thumb_info = getimagesize($thumb_location);
     $post['thumb_width'] = $thumb_info[0];
     $post['thumb_height'] = $thumb_info[1];
     $post['file_original'] = cleanString($embed['title']);
     $post['file'] = str_ireplace(array('src="https://', 'src="http://'), 'src="//', $embed['html']);
 } else {
     if (isset($_FILES['file'])) {
         if ($_FILES['file']['name'] != "") {
             validateFileUpload();
             if (!is_file($_FILES['file']['tmp_name']) || !is_readable($_FILES['file']['tmp_name'])) {
                 fancyDie("File transfer failure. Please retry the submission.");
             }
             if (TINYIB_MAXKB > 0 && filesize($_FILES['file']['tmp_name']) > TINYIB_MAXKB * 1024) {
                 fancyDie("That file is larger than " . TINYIB_MAXKBDESC . ".");
             }
             $post['file_original'] = trim(htmlentities(substr($_FILES['file']['name'], 0, 50), ENT_QUOTES));
             $post['file_hex'] = md5_file($_FILES['file']['tmp_name']);
             $post['file_size'] = $_FILES['file']['size'];
             $post['file_size_formatted'] = convertBytes($post['file_size']);
             // Uploaded file type
             $file_type = strtolower(preg_replace('/.*(\\..+)/', '\\1', $_FILES['file']['name']));
             if ($file_type == '.jpeg') {
                 $file_type = '.jpg';
             }
コード例 #2
0
ファイル: upload.php プロジェクト: bvigar/MeTube
<?php

require_once SERVER_ROOT . 'include/defs.php.inc';
require_once SERVER_ROOT . 'include/db.php';
include SERVER_ROOT . 'views/header.php';
debug_print("HERE");
$error = NULL;
$success = false;
/* here we check for submitted files from the form */
if (isset($_FILES["file"])) {
    /* set default file upload permissions to 755 */
    umask(022);
    $return = validateFileUpload($_FILES["file"]);
    switch ($return) {
        case FILE_VALID:
            break;
        case FILE_ALREADY_EXISTS:
            $error = "ERROR : file already exists on server.";
            goto error;
            break;
        case FILE_SIZE_TOO_LARGE:
            $error = "ERROR : file size too large. Please make sure file is 20MB or smaller.";
            goto error;
            break;
        case FILE_INVALID_TYPE:
            debug_print("invalid file type");
            $error = "ERROR : file type is invalid. Supported file types : \"gif\", \"jpeg\", \"jpg\", \"png\", \"mp3\", \"mp4\", \"mov\", \"wmv\", \"flv\", \"avi\"";
            goto error;
            break;
        default:
            $error = "UNKNOWN ERROR : " . $_FILES["file"]["error"];