• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP getFileType函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中getFileType函数的典型用法代码示例。如果您正苦于以下问题:PHP getFileType函数的具体用法?PHP getFileType怎么用?PHP getFileType使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了getFileType函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: listFile

function listFile($path)
{
    global $config;
    $filetype = getFileType($path);
    if ($filetype == 'text') {
        $text = file_get_contents($config['files'] . $path);
    } else {
        if ($filetype == 'opendocument.text') {
            require "ophir.php";
            $OPHIR_CONF["header"] = 1;
            $OPHIR_CONF["quote"] = 1;
            $OPHIR_CONF["list"] = 1;
            $OPHIR_CONF["table"] = 1;
            $OPHIR_CONF["footnote"] = 1;
            $OPHIR_CONF["link"] = 1;
            $OPHIR_CONF["image"] = 1;
            $OPHIR_CONF["note"] = 1;
            $OPHIR_CONF["annotation"] = 1;
            $text = odt2html($config['files'] . $path);
        } else {
            $text = '';
        }
    }
    return array('type' => 'file', 'filetype' => $filetype, 'mimetype' => system_extension_mime_type($path), 'name' => basename($path), 'path' => $path, 'text' => $text);
}
开发者ID:Dirbaio,项目名称:TurboFile,代码行数:25,代码来源:list.php


示例2: display_company_image_from_string

function display_company_image_from_string($company_name, $row_number, $extra = "")
{
    $data = json_decode(query_an_image($company_name . " " . $extra));
    $img_urls = array();
    $img_names = array();
    foreach ($data->responseData->results as $result) {
        $img_urls[] = $result->url;
        $img_names[] = "/var/www/html/parse-data-dot-com/images/{$row_number}";
        $results[] = array('url' => $result->url, 'alt' => $result->title);
        $url = $result->url;
        $ftype = getFileType($url);
        #echo $ftype;
        $img = "/var/www/html/parse-data-dot-com/images/{$row_number}.{$ftype}";
        echo $url;
        #echo $img;
        if (strpos($url, "https") < 0) {
            //using asfiletype=png
            continue 2;
        } else {
            try {
                return $url;
            } catch (Exception $e) {
                echo "Caught exceptiom : {$e}";
                continue;
            }
        }
    }
    #var_dump($url);
    #var_dump($img);
    return $data;
}
开发者ID:juliusakula,项目名称:clients-ktc,代码行数:31,代码来源:CURLQuery.php


示例3: _initialize

 /**
  * Initialize the upload class
  * @param string $upload The key value of the $_FILES superglobal to use
  */
 private function _initialize($upload)
 {
     $this->_uploadedFile = $upload['name'];
     $this->_tempName = $upload['tmp_name'];
     $this->_fileSize = $upload['size'];
     $this->_extension = getFileExtension($this->_uploadedFile);
     $this->_mimeType = getFileType($this->_tempName);
 }
开发者ID:ITESolutions,项目名称:desktop,代码行数:12,代码来源:Upload.php


示例4: handleUpload

/**
 * Handle and read uploaded file
 * @param array - fileArray from form
 * @param array - postArray from form
 */
function handleUpload($_FILES, $_POST)
{
    require_once "JotForm.php";
    $path = mktime() . '_' . $_FILES['file']['name'];
    $key = $_POST['APIkey'];
    $form = $_POST['formID'];
    $jot = new JotForm($key);
    $error = "";
    if (move_uploaded_file($_FILES['file']['tmp_name'], $path)) {
        $fileType = getFileType($path);
        $columns = array();
        if ($fileType == 'csv') {
            if (($handle = fopen($path, "r")) !== FALSE) {
                if (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
                    foreach ($data as $title) {
                        array_push($columns, $title);
                    }
                }
                $error = 'File must contain at least two rows - the first represents the field titles';
                while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
                    $error = '';
                    $result = $jot->createFormSubmissions($form, writeData($data, $columns));
                }
                fclose($handle);
            } else {
                $error = 'Could not open file';
            }
        } else {
            require_once 'Excel/reader.php';
            $excel = new Spreadsheet_Excel_Reader();
            $excel->read($path);
            if ($excel->sheets[0]['numRows'] > 1) {
                for ($i = 1; $i <= $excel->sheets[0]['numCols']; $i++) {
                    $title = $excel->sheets[0]['cells'][1][$i];
                    array_push($columns, $title);
                }
                for ($i = 2; $i <= $excel->sheets[0]['numRows']; $i++) {
                    $data = array();
                    for ($j = 1; $j <= $excel->sheets[0]['numCols']; $j++) {
                        array_push($data, $excel->sheets[0]['cells'][$i][$j]);
                    }
                    $jot->createFormSubmissions($form, writeData($data, $columns));
                }
            } else {
                $error = 'File must contain at least two rows - the first represents the field titles';
            }
        }
    } else {
        $error = 'No File Found';
    }
    if (strlen($error) > 0) {
        return $error;
    } else {
        return 'none';
    }
}
开发者ID:abmedia,项目名称:api-use-cases,代码行数:61,代码来源:import.php


示例5: generate_name

function generate_name($data)
{
    $fileType = getFileType($data);
    $base = "temp";
    if (isset($_POST["guid"])) {
        $base = $_POST["guid"];
    }
    $date = new DateTime();
    $timestamp = $date->getTimestamp();
    return $base . "-" . $timestamp . $fileType;
}
开发者ID:shadowbeam,项目名称:img-srch,代码行数:11,代码来源:file-upload.php


示例6: get_company_image_from_string

function get_company_image_from_string($company_name, $row_number, $extra = "")
{
    $data = json_decode(query_an_image($company_name . $extra));
    var_dump($data);
    $img_urls = array();
    $img_names = array();
    foreach ($data->responseData->results as $result) {
        $img_urls[] = $result->url;
        $img_names[] = "C:/git-lyris/parse-data-dot-com/images/{$row_number}";
        $results[] = array('url' => $result->url, 'alt' => $result->title);
        $url = $result->url;
        $ftype = getFileType($url);
        #echo $ftype;
        $img = "C:/git-lyris/parse-data-dot-com/images/{$row_number}.{$ftype}";
        echo $url;
        #echo $img;
        if (strpos($url, "https") < 0) {
            //using asfiletype=png
            continue 2;
        } else {
            try {
                echo "<-downloading..\n";
                if (file_put_contents($img, file_get_contents($url))) {
                    break;
                } else {
                    echo "notif file put??";
                    continue;
                }
            } catch (Exception $e) {
                echo "Caught exceptiom : {$e}";
                continue;
            }
        }
    }
    #var_dump($url);
    #var_dump($img);
    return $data;
}
开发者ID:juliusakula,项目名称:clients-ktc,代码行数:38,代码来源:CURLQuery.php


示例7: chkFile


//.........这里部分代码省略.........
                case 4:
                    break;
                case 'UPLOAD_ERR_INI_SIZE':
                case 1:
                    __error("[{$tmp_filename}] 파일 용량이 " . ini_get("upload_max_filesize") . "를 초과할 수 없습니다.\\n(php.ini, upload_max_filesize 설정에서 변경가능)");
                case 'UPLOAD_ERR_FORM_SIZE':
                case 2:
                    __error("[{$tmp_filename}] 파일 용량이 초과 되었습니다.\\n(해당 Form 의 MAX_FILE_SIZE 설정에서 변경 가능합니다)");
                case 'UPLOAD_ERR_PARTIAL':
                case 3:
                    __error("[{$tmp_filename}] 업로드된 파일이 올바르지 않습니다");
                case 'UPLOAD_ERR_NO_TMP_DIR':
                case 6:
                    __error("임시 폴더가 없어 파일을 업로드 할 수 없습니다. 서버 관리자에게 문의해 주세요.\\n(설정된 임시 폴더는 " . ini_get("upload_tmp_dir") . " 입니다)");
                case 'UPLOAD_ERR_CANT_WRITE':
                case 7:
                    __error("디스크에 쓰기를 실패 했습니다. 서버 관리자에게 문의해 주세요");
            }
        }
        //// 파일명 체크
        if ($param['filename']) {
            $filename = $param['filename'];
        }
        $filename = str_replace(array("|", "'", "\"", "\\"), "", $filename);
        $filename = trim($filename);
        //// 확장자 체크
        $val['ext'] = strtolower(substr(strrchr($filename, "."), 1));
        //// 이미지 관련 체크
        $is_image = getimagesize($val['tmp_name']);
        if (!empty($is_image) && is_array($is_image)) {
            $val['is_image'] = 1;
            $val['width'] = $is_image[0];
            $val['height'] = $is_image[1];
        } else {
            $val['is_image'] = 0;
        }
        //// 파일타입
        $val['type'] = getFileType($val['ext']);
        if ($val['type'] == 'image' && empty($val['is_image'])) {
            __error("[{$tmp_filename}] 이미지 파일이 아닙니다");
        }
        if (!$val['is_image'] && $param['is_image']) {
            __error("[{$tmp_filename}] 이미지 파일만 허용합니다");
        }
        if ($val['is_image']) {
            if ($param['width'] && $param['width'] < $val['width']) {
                __error("[{$tmp_filename}] 이미지 너비가 {$param['width']}px 를 초과 했습니다. (현재 {$val['width']}px)");
            }
            if ($param['height'] && $param['height'] < $val['height']) {
                __error("[{$tmp_filename}] 이미지 높이가 {$param['height']}px 를 초과 했습니다. (현재 {$val['height']}px)");
            }
        }
        //// 한글제거
        if (strCut($filename, 0, 'multi')) {
            $filename = urlencode($filename);
        }
        //// 기호제거
        $filename = preg_replace("/[^0-9a-z_\\-\\.]/i", "", $filename);
        //// 파일명 변경
        if ($param['is_download']) {
            $filename = str_replace(".", "_", $filename);
            $filename .= ".mb";
        }
        //// 중복 체크
        if (file_exists($param['dir'] . $filename) && !$param['is_overwrite']) {
            if ($param['is_exists']) {
                __error("[{$tmp_filename}] 중복된 파일명입니다.");
            }
            $a = 0;
            $tmp2_filename = $filename;
            while (file_exists($param['dir'] . $tmp2_filename)) {
                $a++;
                if (strpos($filename, ".") !== false) {
                    $tmp2_filename = preg_replace("/(\\.?[^\\.]+)\$/is", $a . "\\1", $filename);
                } else {
                    $tmp2_filename = $filename . $a;
                }
            }
            $filename = $tmp2_filename;
        }
        //// 내용 중복
        if (!empty($val['size']) && !empty($mini['board']['use_file_unique']) && !empty($mini['board']['no'])) {
            if (sql("SELECT COUNT(*) FROM {$mini['name']['file']} WHERE id={$mini['board']['no']} and hash='" . str(getHash($val), 'encode', 1) . "'")) {
                __error("[{$tmp_filename}] 이미 같은 파일이 있습니다");
            }
        }
        //// 용량 체크
        if ($param['size'] && $param['size'] < $val['size']) {
            __error("[{$tmp_filename}] 파일 용량이 " . number_format($param['size']) . " bytes를 초과할 수 없습니다\\n(현재 {$val['size']}bytes)");
        }
        if ($val['size'] <= 0) {
            __error("[{$tmp_filename}] 파일 용량은 0 byte 이상이어야 합니다");
        }
        //// 변수 입력
        $val['path'] = $param['dir'] . $filename;
        $val['path_only'] = $param['dir'];
        $val['name_insert'] = $filename;
        $_FILES[$key] = $val;
    }
}
开发者ID:bluecat,项目名称:iiwork-php,代码行数:101,代码来源:ii.write.php


示例8: checkFileExists

function checkFileExists($type, $file_name, $folder_path)
{
    $ftp_rawlist = getFtpRawList($folder_path);
    if (is_array($ftp_rawlist)) {
        $fileNameAr = array();
        $count = 0;
        // Go through array of files/folders
        foreach ($ftp_rawlist as $ff) {
            $count++;
            // Lin
            if ($_SESSION["win_lin"] == "lin") {
                // Split up array into values
                $ff = preg_split("/[\\s]+/", $ff, 9);
                $perms = $ff[0];
                $file = $ff[8];
                if ($file != "." && $file != "..") {
                    if ($type == "f" && getFileType($perms) == "f") {
                        $fileNameAr[] = $file;
                    }
                    if ($type == "d" && getFileType($perms) == "d") {
                        $fileNameAr[] = $file;
                    }
                }
            }
            // Mac
            if ($_SESSION["win_lin"] == "mac") {
                if ($count == 1) {
                    continue;
                }
                // Split up array into values
                $ff = preg_split("/[\\s]+/", $ff, 9);
                $perms = $ff[0];
                $file = $ff[8];
                if ($file != "." && $file != "..") {
                    if ($type == "f" && getFileType($perms) == "f") {
                        $fileNameAr[] = $file;
                    }
                    if ($type == "d" && getFileType($perms) == "d") {
                        $fileNameAr[] = $file;
                    }
                }
            }
            // Win
            if ($_SESSION["win_lin"] == "win") {
                // Split up array into values
                $ff = preg_split("/[\\s]+/", $ff, 4);
                $size = $ff[2];
                $file = $ff[3];
                if ($size == "<DIR>") {
                    $size = "d";
                }
                if ($type == "d" && $size == "d") {
                    $fileNameAr[] = $file;
                }
                if ($type == "f" && $size != "d") {
                    $fileNameAr[] = $file;
                }
            }
        }
        // Check if file is in array
        if (in_array($file_name, $fileNameAr)) {
            return 1;
        }
    } else {
        return 0;
    }
}
开发者ID:joyeop,项目名称:Monsta-FTP,代码行数:67,代码来源:index.php


示例9: imgupload

 function imgupload()
 {
     //首先获取上传的总文件数目!
     $imgcount = count($_FILES["files"]["name"]);
     //定义返回的数组
     $backArr = array();
     //根据数量逐个遍历文件
     for ($i = 0; $i <= $imgcount - 1; $i++) {
         $msg = "";
         if ($_FILES['files']['error'][$i] != UPLOAD_ERR_OK) {
             switch ($_FILES['files']['error']) {
                 case UPLOAD_ERR_INI_SIZE:
                     //其值为 1,上传的文件超过了 php.ini 中 upload_max_filesize 选项限制的值
                     $msg = "文件超大!错误代码1";
                     break;
                 case UPLOAD_ERR_FORM_SIZE:
                     //其值为 2,上传文件的大小超过了 HTML 表单中 MAX_FILE_SIZE 选项指定的值
                     $msg = "文件超大!错误代码2";
                     break;
                 case UPLOAD_ERR_PARTIAL:
                     //其值为 3,文件只有部分被上传
                     $msg = "文件未上传完毕!错误代码3";
                     break;
                 case UPLOAD_ERR_NO_FILE:
                     //其值为 4,没有文件被上传
                     $msg = "没有文件被上传!请检查!错误代码4";
                     break;
                 case UPLOAD_ERR_NO_TMP_DIR:
                     //其值为 6,找不到临时文件夹
                     $msg = "服务端错误!未找到临时文件夹!错误代码5";
                     break;
                 case UPLOAD_ERR_CANT_WRITE:
                     //其值为 7,文件写入失败
                     $msg = "文件写入失败!错误代码6";
                     break;
                 case UPLOAD_ERR_EXTENSION:
                     //其他异常
                     $msg = "未知错误!请联系软件人员!错误代码7";
                     break;
             }
         }
         if ($msg == "") {
             //图片正常接收 将文件发送到文件夹并且改名
             /*getimagesize方法返回一个数组,
               $width : 索引 0 包含图像宽度的像素值,
               $height : 索引 1 包含图像高度的像素值,
               $type : 索引 2 是图像类型的标记:
               1 = GIF,2 = JPG, 3 = PNG, 4 = SWF, 5 = PSD, 6 = BMP,
               7 = TIFF(intel byte order),8 = TIFF(motorola byte order),
               9 = JPC,10 = JP2,11 = JPX,12 = JB2,13 = SWC,14 = IFF,15 = WBMP,16 = XBM,
               $attr : 索引 3 是文本字符串,内容为“height="yyy" width="xxx"”,可直接用于 IMG 标记
               */
             list($width, $height, $type, $attr) = getimagesize($_FILES['files']['tmp_name'][$i]);
             //imagecreatefromgXXX方法从一个url路径中创建一个新的图片
             switch ($type) {
                 case IMAGETYPE_GIF:
                     $image = imagecreatefromgif($_FILES['files']['tmp_name'][$i]);
                     $ext = '.gif';
                     break;
                 case IMAGETYPE_JPEG:
                     $image = imagecreatefromjpeg($_FILES['files']['tmp_name'][$i]);
                     $ext = '.jpg';
                     break;
                 case IMAGETYPE_PNG:
                     $image = imagecreatefrompng($_FILES['files']['tmp_name'][$i]);
                     $ext = '.png';
                     break;
                 default:
                     $msg = "所发送的文件并非为需要接收的格式!请检查!错误代码8!";
             }
             //有url指定的图片创建图片并保存到指定目录
             $imagename = uniqid() . "." . getFileType($_FILES['files']['name'][$i]);
             imagegif($image, $this->_imgdir . '/' . $imagename);
             //销毁由url生成的图片
             imagedestroy($image);
         } else {
             $imagename = $_FILES['files']['name'][$i];
         }
         $backArr[$i] = array("msg" => "{$msg}", "imagename" => "{$imagename}");
     }
     return $backArr;
 }
开发者ID:suollk,项目名称:KLBSalary,代码行数:82,代码来源:formModel.class.php


示例10: deleteFile

function deleteFile($d, $del = true)
{
    $size = 0;
    $t = getFileType($d);
    if ($t == 't') {
        // For time lapse try to delete all from this batch
        $files = findLapseFiles($d);
        foreach ($files as $file) {
            $size += filesize_n($file);
            if ($del) {
                if (!unlink($file)) {
                    $debugString .= "F ";
                }
            }
        }
    } else {
        $tFile = dataFilename($d);
        if (file_exists(LBASE_DIR . '/' . MEDIA_PATH . "/{$tFile}")) {
            $size += filesize_n(LBASE_DIR . '/' . MEDIA_PATH . "/{$tFile}");
            if ($del) {
                unlink(LBASE_DIR . '/' . MEDIA_PATH . "/{$tFile}");
            }
        }
        if ($t == 'v' && file_exists(LBASE_DIR . '/' . MEDIA_PATH . "/{$tFile}.dat")) {
            $size += filesize_n(LBASE_DIR . '/' . MEDIA_PATH . "/{$tFile}.dat");
            if ($del) {
                unlink(LBASE_DIR . '/' . MEDIA_PATH . "/{$tFile}.dat");
            }
        }
    }
    $size += filesize_n(LBASE_DIR . '/' . MEDIA_PATH . "/{$d}");
    if ($del) {
        unlink(LBASE_DIR . '/' . MEDIA_PATH . "/{$d}");
    }
    return $size / 1024;
}
开发者ID:zepspaiva,项目名称:RPi_Cam_Web_Interface,代码行数:36,代码来源:config.php


示例11: opendir

			<?php 
    $dirs = opendir($idir);
    ?>
			<?php 
    while (false !== ($f = readdir($dirs))) {
        ?>
			<?php 
        if (!is_file($idir . $f)) {
            continue;
        }
        ?>
			<?php 
        $fext = getExt($f);
        ?>
			<?php 
        $ftype = getFileType($fext);
        ?>
			

				<div class="imgbox" title="<?php 
        echo $f;
        ?>
">
					<div class="delbox"><a href="<?php 
        echo $g['s'];
        ?>
/?r=<?php 
        echo $r;
        ?>
&amp;m=<?php 
        echo $module;
开发者ID:hoya0704,项目名称:trevia.co.kr,代码行数:31,代码来源:main.php


示例12: drawFile

function drawFile($f, $ts, $sel)
{
    $fType = getFileType($f);
    $rFile = dataFilename($f);
    $fNumber = getFileIndex($f);
    $lapseCount = "";
    switch ($fType) {
        case 'v':
            $fIcon = 'video.png';
            break;
        case 't':
            $fIcon = 'timelapse.png';
            $lapseCount = '(' . count(findLapseFiles($f)) . ')';
            break;
        case 'i':
            $fIcon = 'image.png';
            break;
        default:
            $fIcon = 'image.png';
            break;
    }
    $duration = '';
    if (file_exists(MEDIA_PATH . "/{$rFile}")) {
        $fsz = round(filesize(MEDIA_PATH . "/{$rFile}") / 1024);
        $fModTime = filemtime(MEDIA_PATH . "/{$rFile}");
        if ($fType == 'v') {
            $duration = $fModTime - filemtime(MEDIA_PATH . "/{$f}") . 's';
        }
    } else {
        $fsz = 0;
        $fModTime = filemtime(MEDIA_PATH . "/{$f}");
    }
    $fDate = @date('Y-m-d', $fModTime);
    $fTime = @date('H:i:s', $fModTime);
    $fWidth = max($ts + 4, 140);
    echo "<fieldset class='fileicon' style='width:" . $fWidth . "px;'>";
    echo "<legend class='fileicon'>";
    echo "<button type='submit' name='delete1' value='{$f}' class='fileicondelete' style='background-image:url(delete.png);\n'></button>";
    echo "&nbsp;&nbsp;{$fNumber}&nbsp;";
    echo "<img src='{$fIcon}' style='width:24px'/>";
    echo "<input type='checkbox' name='check_list[]' {$sel} value='{$f}' style='float:right;'/>";
    echo "</legend>";
    if ($fsz > 0) {
        echo "{$fsz} Kb {$lapseCount} {$duration}";
    } else {
        echo 'Busy';
    }
    echo "<br>{$fDate}<br>{$fTime}<br>";
    if ($fsz > 0) {
        echo "<a title='{$rFile}' href='preview.php?preview={$f}'>";
    }
    echo "<img src='" . MEDIA_PATH . "/{$f}' style='width:" . $ts . "px'/>";
    if ($fsz > 0) {
        echo "</a>";
    }
    echo "</fieldset> ";
}
开发者ID:0legg,项目名称:RPi_Cam_Web_Interface,代码行数:57,代码来源:preview.php


示例13: number_format

            $fSize = @filesize($entry);
            $f["size"] = $fSize;
            $f["fullSize"] = number_format($fSize, 0, ".", ",");
            $f["niceSize"] = nicesize($fSize);
            $pi = pathinfo($entry);
            $f["type"] = $pi["extension"];
            $f["link"] = myEncode($path, $entry);
            if (in_array("cvsversion", $displayColumns)) {
                $f["cvsversion"] = getVersion($entry);
            }
        }
    }
    if (!$f["isBack"]) {
        $f["displayName"] = htmlentities(iTrunc($f["name"], $truncateLength));
    }
    $f["filetype"] = getFileType($f);
    $f["icon"] = getIcon($f["filetype"]);
    if ($useAutoThumbnails && $f["filetype"] == "image") {
        $f["thumbnail"] = "<a href=\"" . urldecode($f["link"]) . "\"><img src=\"" . $PHP_SELF . "?thumbnail=" . urlencode($path . $f["name"]) . "\" style=\"text-align: left;\" alt=\"\"/></a>";
    }
    $files[] = $f;
}
usort($files, "myCompare");
$pagingInEffect = $usePaging > 0 && count($files) > $usePaging;
if ($usePaging > 0) {
    $pageStart = $_GET["start"];
    if ($pageStart == "" || $pageStart < 0 || $pageStart > count($files)) {
        $pageStart = 0;
    }
    $pagingActualPage = floor($pageStart / $usePaging);
    $pagingNumberOfPages = ceil(count($files) / $usePaging);
开发者ID:stsquad,项目名称:CODEF,代码行数:31,代码来源:index.php


示例14: getThumbnails

function getThumbnails()
{
    global $sortOrder;
    global $showTypes;
    global $timeFilter, $timeFilterMax;
    $files = scandir(MEDIA_PATH, $sortOrder - 1);
    $thumbnails = array();
    $nowTime = time();
    foreach ($files as $file) {
        if ($file != '.' && $file != '..' && isThumbnail($file)) {
            if ($timeFilter == 1) {
                $include = true;
            } else {
                $timeD = $nowTime - filemtime(MEDIA_PATH . "/{$file}");
                if ($timeFilter == $timeFilterMax) {
                    $include = $timeD >= 86400 * ($timeFilter - 1);
                } else {
                    $include = $timeD >= 86400 * ($timeFilter - 2) && $timeD < ($timeFilter - 1) * 86400;
                }
            }
            if ($include) {
                $fType = getFileType($file);
                if ($showTypes == '1') {
                    $thumbnails[] = $file;
                } elseif ($showTypes == '2' && ($fType == 'i' || $fType == 't')) {
                    $thumbnails[] = $file;
                } elseif ($showTypes == '3' && $fType == 'v') {
                    $thumbnails[] = $file;
                }
            }
        }
    }
    return $thumbnails;
}
开发者ID:TurtleS0up03,项目名称:archive,代码行数:34,代码来源:preview.php


示例15: openFile

function openFile()
{
    global $sage_data_dir;
    $filename = $_REQUEST["filename"];
    if ($path = "") {
        return false;
    }
    $fspath = $sage_data_dir . $_SESSION["path"] . "/" . $filename;
    if (!file_exists($fspath)) {
        return false;
    }
    $filesize = filesize($fspath);
    $mime = getFileType($fspath);
    header("Content-Type: {$mime}");
    header("Content-Disposition: attachment; filename={$filename}");
    //header("Content-Length: $filesize ");
    readfile($fspath);
}
开发者ID:BackupTheBerlios,项目名称:sage,代码行数:18,代码来源:browser.php


示例16: basename

<?php

$target_dir = "media/";
$target_file = $target_dir . basename($_FILES["file"]["name"]);
$file_type = getFileType($_FILES["file"]["name"]);
//Only mp3 and ogg file supported
if ($file_type != "mp3" && $file_type != "ogg") {
    echo "Sorry, only MP3 & OGG files are allowed.";
    return;
}
// Check if file already exists
if (file_exists($target_file)) {
    echo "Sorry, file already exists.";
    return;
}
// Try to upload to server
if (move_uploaded_file($_FILES["file"]["tmp_name"], $target_file)) {
    $response = "The file has been uploaded.";
    echo $response;
    return;
} else {
    $response = "Sorry, there was an error uploading your file.";
    echo $response;
    return;
}
function getFileType($file)
{
    $path_chunks = explode("/", $file);
    $thefile = $path_chunks[count($path_chunks) - 1];
    $dotpos = strrpos($thefile, ".");
    return strtolower(substr($thefile, $dotpos + 1));
开发者ID:steveimc,项目名称:MediaPlayer,代码行数:31,代码来源:upload.php


示例17: putFile2AmazonS3

function putFile2AmazonS3($fileName, $path)
{
    $key = "AKIAJ2DAWLHW6BGOQUTA";
    $secret = "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";
    $s3 = new S3($key, $secret);
    //$bucket = "slot-saga";
    $bucket = "res.enjoygameinc.com";
    $url = $fileName;
    $contentType = getFileType($fileName);
    if ($s3->putObjectFile($path, $bucket, $url, S3::ACL_PUBLIC_READ, array(), $contentType)) {
        return true;
    }
    return false;
}
开发者ID:maomaotp,项目名称:up2S3,代码行数:14,代码来源:s3.php


示例18: getLink

         getLink('', '', _LANG('a5001', 'mediaset'), '');
     }
     if (!$FTP_CRESULT) {
         getLink('', '', _LANG('a5001', 'mediaset'), '');
     }
     if ($d['mediaset']['ftp_pasv']) {
         ftp_pasv($FTP_CONNECT, true);
     }
     ftp_chdir($FTP_CONNECT, $d['mediaset']['ftp_folder']);
 }
 for ($i = 0; $i < $upfileNum; $i++) {
     $name = strtolower($_FILES['upfiles']['name'][$i]);
     $size = $_FILES['upfiles']['size'][$i];
     $fileExt = getExt($name);
     $fileExt = $fileExt == 'jpeg' ? 'jpg' : $fileExt;
     $type = getFileType($fileExt);
     $tmpname = md5($name) . substr($date['totime'], 8, 14);
     $tmpname = $type == 5 ? $tmpname . '.' . $fileExt : $tmpname;
     $hidden = $type == 5 ? 1 : 0;
     if ($fileExt != 'mp4') {
         continue;
     }
     if ($fserver) {
         for ($j = 1; $j < 4; $j++) {
             ftp_mkdir($FTP_CONNECT, $d['mediaset']['ftp_folder'] . str_replace('./files/', '', ${'savePath' . $j}));
         }
         ftp_put($FTP_CONNECT, $d['mediaset']['ftp_folder'] . $folder . '/' . $tmpname, $_FILES['upfiles']['tmp_name'][$i], FTP_BINARY);
     } else {
         for ($j = 1; $j < 4; $j++) {
             if (!is_dir(${'savePath' . $j})) {
                 mkdir(${'savePath' . $j}, 0707);
开发者ID:hanacody,项目名称:rb2,代码行数:31,代码来源:a.upload_vod.php


示例19: mkdir

             mkdir(${'savePath' . $i}, 0707);
             @chmod(${'savePath' . $i}, 0707);
         }
     }
 }
 for ($i = 0; $i < $num_upfile + $num_photo; $i++) {
     if (!$_FILES['upfile']['tmp_name'][$i]) {
         continue;
     }
     $width = 0;
     $height = 0;
     $up_name = strtolower($_FILES['upfile']['name'][$i]);
     $up_size = $_FILES['upfile']['size'][$i];
     $up_fileExt = getExt($up_name);
     $up_fileExt = $up_fileExt == 'jpeg' ? 'jpg' : $up_fileExt;
     $up_type = getFileType($up_fileExt);
     $up_tmpname = md5($up_name) . substr($date['totime'], 8, 14);
     $up_tmpname = $up_type == 2 ? $up_tmpname . '.' . $up_fileExt : $up_tmpname;
     $up_mingid = getDbCnt($table['s_upload'], 'min(gid)', '');
     $up_gid = $up_mingid ? $up_mingid - 1 : 100000000;
     $up_saveFile = $savePath3 . '/' . $up_tmpname;
     $up_hidden = $up_type == 2 ? 1 : 0;
     if ($fserver) {
         if ($up_type == 2) {
             $up_thumbname = md5($up_tmpname);
             $up_thumbFile = $g['path_tmp'] . 'backup/' . $up_thumbname;
             ResizeWidth($_FILES['upfile']['tmp_name'][$i], $up_thumbFile, 150);
             $IM = getimagesize($_FILES['upfile']['tmp_name'][$i]);
             $width = $IM[0];
             $height = $IM[1];
             ftp_put($FTP_CONNECT, $d['upload']['ftp_folder'] . $up_folder . '/' . $up_thumbname, $up_thumbFile, FTP_BINARY);
开发者ID:kiminmug,项目名称:rb_module_bbs,代码行数:31,代码来源:a.write_h.php


示例20: date

 $subpath = $settingInfo['attachDir'] == "1" ? date("Ym") . "/" : "";
 $path = "../attachments/" . $subpath;
 $fileName = $_FILES["attfile"]["name"];
 $fileSize = $_FILES["attfile"]["size"];
 $updateStyle = $_FILES["attfile"]["type"];
 $info = $fileName . " (" . formatFileSize($fileSize) . ")";
 $attdesc = trim($_POST['attdesc']);
 //可以为空
 $attachment = upload_file($attachment_file, $fileName, $path);
 if ($attachment == "") {
     print_message($strAttachmentsError);
     $action = "";
 } else {
     $value = $subpath . $attachment;
     $basefile = "../attachments/" . $value;
     $fileType = getFileType($fileName);
     if ($imageAtt = getimagesize($path . $attachment)) {
         $fileWidth = $imageAtt[0];
         $fileHeight = $imageAtt[1];
     } else {
         $fileWidth = 0;
         $fileHeight = 0;
     }
     // 判断是否为图片格式
     if ($fileType == 'gif' || $fileType == 'jpg' || $fileType == 'jpeg' || $fileType == 'png') {
         // 判断是否使用缩略图
         if ($settingInfo['genThumb'] == "1") {
             $tsize = explode('x', strtolower($settingInfo['thumbSize']));
             if ($fileWidth > $tsize[0] || $fileHeight > $tsize[1]) {
                 $attach_thumb = array('filepath' => "../attachments/" . $value, 'filename' => $attachment, 'extension' => $fileType, 'thumbswidth' => $tsize[0], 'thumbsheight' => $tsize[1]);
                 $thumb_data = generate_thumbnail($attach_thumb);
开发者ID:BGCX067,项目名称:f2cont-svn-to-git,代码行数:31,代码来源:attach.php



注:本文中的getFileType函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP getFileUrl函数代码示例发布时间:2022-05-15
下一篇:
PHP getFileName函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap