当前位置: 首页>>代码示例>>PHP>>正文


PHP getExt函数代码示例

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


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

示例1: thumb

function thumb($filename, $destination = null, $dst_w = null, $dst_h = null, $isReservedSource = true, $scale = 0.5)
{
    //getimagesize() —— 取得图片的长宽。
    list($src_w, $src_h, $imagetype) = getimagesize($filename);
    if (is_null($dst_w) || is_null($dst_h)) {
        $dst_w = ceil($src_w * $scale);
        $dst_h = ceil($src_h * $scale);
    }
    $mime = image_type_to_mime_type($imagetype);
    $createFun = str_replace("/", null, $mime);
    $outFun = str_replace("/", null, $mime);
    $src_image = $createFun($filename);
    $dst_image = imagecreatetruecolor($dst_w, $dst_h);
    //imagecopyresampled — 重采样拷贝部分图像并调整大小
    imagecopyresampled($dst_image, $src_image, 0, 0, 0, 0, $dst_w, $dst_h, $src_w, $src_h);
    if ($destination && !file_exists(dirname($destination))) {
        mkdir(dirname($destination), 0777, TRUE);
    }
    $dstFilename = $destination = null ? getUniName() . "." . getExt($filename) : $destination;
    $outFun($dst_image, $dstFilename);
    imagedestroy($src_image);
    imagedestroy($dst_image);
    if (!$isReservedSource) {
        unlink($filename);
    }
    return $dstFilename;
}
开发者ID:Arc-lin,项目名称:dankal,代码行数:27,代码来源:image.func.php

示例2: readDirR

function readDirR($dir = "./", $base_path = './', $mp = '')
{
    if ($listing = opendir($dir)) {
        $return = array();
        while (($entry = readdir($listing)) !== false) {
            if ($entry != "." && $entry != ".." && substr($entry, 0, 1) != '.') {
                $dir = preg_replace("/^(.*)(\\/)+\$/", "\$1", $dir);
                $item = $dir . "/" . $entry;
                $isfile = is_file($item);
                $dirend = $isfile ? '' : '/';
                $path_to_file = $dir . "/" . $entry . $dirend;
                $path_to_file = str_replace($mp, $base_path, $path_to_file);
                $link = '<a rel="' . getExt($entry) . '" href="' . $path_to_file . '">' . $entry . '</a>';
                if ($isfile && isValidFile($entry)) {
                    $return[] = $link;
                } elseif (is_dir($item)) {
                    $return[$link] = readDirR($item, $base_path, $mp);
                } else {
                }
            } else {
            }
        }
        return $return;
    } else {
        die('Can\'t read directory.');
    }
}
开发者ID:greg3560,项目名称:plailly,代码行数:27,代码来源:functions.php

示例3: thumb

/**
 * 生成缩略图
 * @param string $filename
 * @param string $destination
 * @param int $dst_w
 * @param int $dst_h
 * @param bool $isReservedSource
 * @param number $scale
 * @return string
 */
function thumb($filename, $destination = null, $dst_w, $dst_h = NULL, $isReservedSource = true)
{
    list($src_w, $src_h, $imagetype) = getimagesize($filename);
    if ($src_w <= $dst_w) {
        $dst_w = $src_w;
        $dst_h = $src_h;
    }
    if (is_null($dst_h)) {
        $dst_h = scaling($src_w, $src_h, $dst_w);
    }
    $mime = image_type_to_mime_type($imagetype);
    $createFun = str_replace("/", "createfrom", $mime);
    $outFun = str_replace("/", null, $mime);
    $src_image = $createFun($filename);
    $dst_image = imagecreatetruecolor($dst_w, $dst_h);
    imagecopyresampled($dst_image, $src_image, 0, 0, 0, 0, $dst_w, $dst_h, $src_w, $src_h);
    if ($destination && !file_exists(dirname($destination))) {
        mkdir(dirname($destination), 0777, true);
    }
    $dstFilename = $destination == null ? getUniName() . "." . getExt($filename) : $destination;
    $outFun($dst_image, $dstFilename);
    imagedestroy($src_image);
    imagedestroy($dst_image);
    if (!$isReservedSource) {
        unlink($filename);
    }
    return $dstFilename;
}
开发者ID:hardihuang,项目名称:happyhome_admin,代码行数:38,代码来源:image.func.php

示例4: thumb

function thumb($filename, $destination = null, $dst_w = null, $dst_h = null, $isReservedSource = false, $scale = 0.5)
{
    list($src_w, $src_h, $imagetype) = getimagesize($filename);
    if (is_null($dst_w) || is_null($dst_h)) {
        $dst_w = ceil($src_w * $scale);
        $dst_h = ceil($src_h * $scale);
    }
    $mime = image_type_to_mime_type($imagetype);
    $createFun = str_replace("/", "createfrom", $mime);
    $outFun = str_replace("/", null, $mime);
    $src_image = $createFun($filename);
    $dst_image = imagecreatetruecolor($dst_w, $dst_h);
    imagecopyresampled($dst_image, $src_image, 0, 0, 0, 0, $dst_w, $dst_h, $src_w, $src_h);
    //image_50/sdfsdkfjkelwkerjle.jpg
    if ($destination && !file_exists(dirname($destination))) {
        mkdir(dirname($destination), 0777, true);
    }
    $dstFilename = $destination == null ? getUniName() . "." . getExt($filename) : $destination;
    $outFun($dst_image, $dstFilename);
    imagedestroy($src_image);
    imagedestroy($dst_image);
    if (!$isReservedSource) {
        unlink($filename);
    }
    return $dstFilename;
}
开发者ID:Wumingla,项目名称:shopImooc,代码行数:26,代码来源:resizeImage2.php

示例5: move_to_temp

 /**
  * Moving file from MASS UPLOAD DIR TO TEMP DIR
  */
 function move_to_temp($file_arr, $file_key)
 {
     $file = $file_arr['file'];
     $mass_file = MASS_UPLOAD_DIR . '/' . $file;
     $temp_file = TEMP_DIR . '/' . $file_key . '.' . getExt($file);
     if (file_exists($mass_file) && is_file($mass_file)) {
         rename($mass_file, $temp_file);
         //copy($mass_file,$temp_file);
         return $file_key . '.' . getExt($file);
     }
     return false;
 }
开发者ID:yukisky,项目名称:clipbucket,代码行数:15,代码来源:mass_upload.class.php

示例6: createThumbnail

function createThumbnail($originImg)
{
    $thumnailExt = getExt($originImg);
    //拡張子によって作り方を変える
    switch ($thumnailExt) {
        case 'jpg':
            $sImg = imagecreatefromjpeg(PHOTO_FOLDER . "/" . $originImg);
            break;
        case 'jpeg':
            $sImg = imagecreatefromjpeg(PHOTO_FOLDER . "/" . $originImg);
            break;
        case 'png':
            $sImg = imagecreatefrompng(PHOTO_FOLDER . "/" . $originImg);
            break;
        case 'gif':
            $sImg = imagecreatefromgif(PHOTO_FOLDER . "/" . $originImg);
            break;
    }
    //画像の幅と高さを取得する
    $width = imagesx($sImg);
    $height = imagesy($sImg);
    if ($width > $height) {
        $size = $height;
        $x = floor(($width - $height) / 2);
        $y = 0;
        $width = $size;
    } else {
        $side = $width;
        $y = floor(($height - $width) / 2);
        $x = 0;
        $height = $side;
    }
    //サムネイルの大きさを決める
    $thumbnail_width = 200;
    $thumbnail_height = 200;
    $thumbnail = imagecreatetruecolor($thumbnail_width, $thumbnail_height);
    imagecopyresized($thumbnail, $sImg, 0, 0, $x, $y, $thumbnail_width, $thumbnail_height, $width, $height);
    switch ($thumnailExt) {
        case 'jpg':
            imagejpeg($thumbnail, THUMNAIL_FOLDER . "/s_" . $originImg);
            break;
        case 'jpeg':
            imagejpeg($thumbnail, THUMNAIL_FOLDER . "/s_" . $originImg);
            break;
        case 'png':
            imagepng($thumbnail, THUMNAIL_FOLDER . "/s_" . $originImg);
            break;
        case 'gif':
            imagegif($thumbnail, THUMNAIL_FOLDER . "/s_" . $originImg);
            break;
    }
}
开发者ID:palpal1988,项目名称:first,代码行数:52,代码来源:index.php

示例7: validate_video_link

/**
 * Function used to validate embed code
 */
function validate_video_link($val)
{
    if (empty($val) || $val == 'none') {
        return 'none';
    } else {
        //checking file exension
        $validExts = array('flv', 'mp4');
        $ext = getExt($val);
        if (!in_array($ext, $validExts) || !stristr($val, 'http://') && !stristr($val, 'https://') && !stristr($val, 'rtsp://') && !stristr($val, 'rtmp://')) {
            return false;
        }
        return $val;
    }
}
开发者ID:reactvideos,项目名称:Website,代码行数:17,代码来源:cb_link_video.php

示例8: download

 public function download()
 {
     $id = intval($_GET['id']);
     $this->loadModel('schnippet');
     $schnippet = new Schnippet();
     $schnippet->load($id);
     if ($schnippet->getMember('protected') == 'on' && (!isset($_SESSION[APP_SES . 'id']) || $_SESSION[APP_SES . 'id'] == 0)) {
         $_SESSION[APP_SES . 'route'] = '/application/schnippets&m=edit&id=' . $_GET['id'];
         gotoUrl('/?route=/users/users');
         exit;
     }
     // remove all non-alphanumeric characters from title to make filename then replace whitespace with underscores
     $title = cleanString($schnippet->getMember('title'));
     // get file extension
     $ext = getExt($schnippet->getMember('lang'));
     header("Content-Type: plain/text");
     header("Content-Disposition: Attachment; filename={$title}.{$ext}");
     header("Pragma: no-cache");
     echo $schnippet->getMember('code');
 }
开发者ID:rexstudio,项目名称:schnippets,代码行数:20,代码来源:schnippets.php

示例9: thumb

/**
 * 生成缩略图
 * @param string $fileName
 * @param string $destination
 * @param int $dst_w
 * @param int $dst_h
 * @param number $scale
 * @param bool $isReservedSource
 * @return Ambigous <string, unknown>
 */
function thumb($fileName, $destination = null, $dst_w = null, $dst_h = null, $scale = 0.5, $isReservedSource = true)
{
    //得到文件类型
    list($src_w, $src_h, $imagetype) = getimagesize($fileName);
    if (is_null($dst_w) || is_null($dst_h)) {
        $dst_w = ceil($src_w * $scale);
        $dst_h = ceil($src_h * $scale);
    }
    $mime = image_type_to_mime_type($imagetype);
    //得到方法名,通过拼接字符串得到,这样子做是为了能够处理不同类型的图片
    $createFun = str_replace("/", "createfrom", $mime);
    $outFun = str_replace("/", null, $mime);
    $src_image = $createFun($fileName);
    $dst_image = imagecreatetruecolor($dst_w, $dst_h);
    imagecopyresampled($dst_image, $src_image, 0, 0, 0, 0, $dst_w, $dst_h, $src_w, $src_h);
    $destination = $destination == null ? getUniName() . '.' . getExt($fileName) : $destination;
    $outFun($dst_image, $destination);
    imagedestroy($dst_image);
    imagedestroy($src_image);
    if (!$isReservedSource) {
        unlink($fileName);
    }
    return $destination;
}
开发者ID:hiden2,项目名称:shopImooc-1,代码行数:34,代码来源:image.func.php

示例10: mk_dir

			echo '没有文件被上传。';
			break;

		default:;

	}

}

//处理文件过程

$pic = $_FILES['pic'];

//拼接文件路径

$path = './' . mk_dir() . '/' . randName() . '.' . getExt($pic['name']);

//移动
if(move_uploaded_file($pic['tmp_name'], $path)){
	echo '文件成功';
}else{
	echo  '上传失败';
	echo '<pre>';
	print_r($pic);
	echo '</pre>';
}

echo '<h3>程序运行结束!</h3>';


开发者ID:xiaoxiaoJun,项目名称:phpper,代码行数:28,代码来源:03.php

示例11: uploadFile

function uploadFile($path = "uploads", $allowExt = array("gif", "jpeg", "png", "jpg", "wbmp"), $maxSize = 2097152, $imgFlag = true)
{
    if (!file_exists($path)) {
        mkdir($path, 0777, true);
    }
    $files = buildInfo();
    $i = 0;
    if (!($files && is_array($files))) {
        return;
    }
    foreach ($files as $file) {
        if ($file['error'] == UPLOAD_ERR_OK) {
            $ext = getExt($file['name']);
            // 检查文件扩展名
            if (!in_array($ext, $allowExt)) {
                exit("非法文件类型");
            }
            // 检查是否真正图片类型
            if ($imgFlag) {
                if (!getimagesize($file['tmp_name'])) {
                    exit("不是真正图片类型");
                }
            }
            // 上传文件的大小
            if ($file['size'] > $maxSize) {
                exit("上传文件过大");
            }
            // 是否通过HTTP POST上传
            if (!is_uploaded_file($file['tmp_name'])) {
                exit("不是通过HTTP POST方式上传");
            }
            $filename = getUniName() . "." . $ext;
            $destination = $path . "/" . $filename;
            if (move_uploaded_file($file['tmp_name'], $destination)) {
                $file['name'] = $filename;
                unset($file['error'], $file['tmp_name'], $file['size'], $file['type']);
                //注销没用信息
                $uploadedFiles[$i] = $file;
                $i++;
            }
        } else {
            switch ($file['error']) {
                case 1:
                    $mes = "超过了配置文件上传文件的大小";
                    // UPLOAD_ERR_INI_SIZE
                    break;
                case 2:
                    $mes = "超过了表单设置上传文件的大小";
                    // UPLOAD_ERR_FORM_SIZE
                    break;
                case 3:
                    $mes = "文件部分被上传";
                    // UPLOAD_ERR_PARTIAL
                    break;
                case 4:
                    $mes = "没有文件被上传";
                    // UPLOAD_ERR_NO_FILE
                    break;
                case 6:
                    $mes = "没有找到临时目录";
                    // UPLOAD_ERR_NO_TMP_DIR
                    break;
                case 7:
                    $mes = "文件不可写";
                    // UPLOAD_ERR_CANT_WRITE
                    break;
                case 8:
                    $mes = "由于PHP的扩展程序终端了文件上传";
                    // UPLOAD_ERR_EXTENSION
            }
            echo $mes;
        }
    }
    return $uploadedFiles;
}
开发者ID:BigeyeDestroyer,项目名称:biogas,代码行数:75,代码来源:upload.func.php

示例12: strtoupper

            <tr<?php 
                    echo $bkg++ % 2 == 0 ? " class=\"okbf_line\"" : "";
                    ?>
>
              <td class="okbf_table_td1"><a href="<?php 
                    echo "{$fData['resource']}/{$value}";
                    ?>
" onclick="window.open('<?php 
                    echo "{$fData['resource']}/{$value}";
                    ?>
', 'fum_viewfile', 'resizable=yes,width=640,height=480,scrollbars=yes,status=no'); return false;"><?php 
                    echo $value;
                    ?>
</a></td>
              <td class="okbf_table_td2"><?php 
                    echo strtoupper(getExt($value));
                    ?>
</td>
              <td class="okbf_table_td2">
                <?php 
                    $file_size = filesize($fData['resource'] . "/{$value}");
                    if ($file_size >= 1073741824) {
                        echo number_format($file_size / 1073741824, 2) . " GB";
                    } else {
                        if ($file_size >= 1048576) {
                            echo number_format($file_size / 1048576, 2) . " MB";
                        } else {
                            if ($file_size >= 1024) {
                                echo number_format($file_size / 1024, 2) . " kB";
                            } else {
                                if ($file_size >= 0) {
开发者ID:juliogallardo1326,项目名称:proc,代码行数:31,代码来源:knowledgebase-control.php

示例13: checkAdmin

<?php

if (!defined('__KIMS__')) {
    exit;
}
checkAdmin(0);
$folder = './';
$tmpname = $_FILES['upfile']['tmp_name'];
$realname = $_FILES['upfile']['name'];
$fileExt = strtolower(getExt($realname));
$extPath = $g['path_tmp'] . 'app';
$extPath1 = $extPath . '/';
$saveFile = $extPath1 . $date['totime'] . '.zip';
if (is_uploaded_file($tmpname)) {
    if (substr($realname, 0, 7) != 'rb_etc_') {
        getLink('', '', '기타자료 패키지가 아닙니다.', '');
    }
    if ($fileExt != 'zip') {
        getLink('', '', '패키지는 반드시 zip압축 포맷이어야 합니다.', '');
    }
    move_uploaded_file($tmpname, $saveFile);
    require $g['path_core'] . 'opensrc/unzip/ArchiveExtractor.class.php';
    require $g['path_core'] . 'function/dir.func.php';
    $extractor = new ArchiveExtractor();
    $extractor->extractArchive($saveFile, $extPath1);
    unlink($saveFile);
    $opendir = opendir($extPath1);
    while (false !== ($file = readdir($opendir))) {
        if ($file != '.' && $file != '..') {
            if (is_file($extPath1 . $file)) {
                if (is_file($folder . $file)) {
开发者ID:hoya0704,项目名称:trevia.co.kr,代码行数:31,代码来源:a.etc_pack_upload.php

示例14: mysqli_stmt_execute

         $_message = $comment["message"] ? $comment["message"] : null;
         mysqli_stmt_execute($dbComment);
         $uids[$_user_id] = $comment["from"]["name"];
         $commentCount++;
         if (isset($comment["attachment"]["media"])) {
             switch ($comment["attachment"]["type"]) {
                 case "photo":
                     $_photo_id = $comment["attachment"]["target"]["id"];
                     $_attached_to = $comment["id"];
                     $_attached_type = "comment";
                     $_album_id = null;
                     $_owner_id = $comment["from"]["id"];
                     $_height = $comment["attachment"]["media"]["image"]["height"];
                     $_width = $comment["attachment"]["media"]["image"]["width"];
                     $_src = $comment["attachment"]["media"]["image"]["src"];
                     $_src_ext = getExt($comment["attachment"]["media"]["image"]["src"]);
                     $_caption = null;
                     $_permalink = $comment["attachment"]["url"];
                     mysqli_stmt_execute($dbPhoto);
                     $pids[] = $_photo_id;
                     $photoCount++;
                     break;
             }
         }
     }
 }
 if (isset($post["comments"]["paging"]["next"])) {
     $post["comments"] = getGraphPage($fb, $post["comments"]["paging"]["next"]);
 } else {
     break;
 }
开发者ID:eduridden,项目名称:extensions,代码行数:31,代码来源:getGroupArchive.php

示例15: header

header('content-type:text/html;charset=utf-8');
//1.给你一个文件名1.txt  1.jpeg 1.txt.png,
//得到文件的扩展名
/**
 * 得到文件的扩展名
 * @param string $filename
 * @return string
 */
function getExt($filename)
{
    $ext = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
    return $ext;
}
echo getExt('1.txt.jpeg');
echo '<br/>';
echo getExt('2.php');
/**
* 默认得到日期2015年8月21日 星期五
// 2015-8-21 星期五 2015/8/21 星期五
* @param string $del1
* @param string $del2
* @param string $del3
* @return string
*/
function getDateStr($del1 = '年', $del2 = '月', $del3 = '日')
{
    $search = array(0, 1, 2, 3, 4, 5, 6);
    $replace = array('日', '一', '二', '三', '四', '五', '六');
    $subject = date('w');
    return date("Y{$del1}m{$del2}d{$del3} 星期") . str_replace($search, $replace, $subject);
}
开发者ID:denson7,项目名称:phpstudy,代码行数:31,代码来源:func5.php


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