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

PHP getExt函数代码示例

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

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



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


示例16: upload_thumb

 function upload_thumb($array)
 {
     global $file_name, $LANG;
     //Get File Name
     $file = $array['name'];
     $ext = getExt($file);
     $image = new ResizeImage();
     if (!empty($file) && file_exists($array['tmp_name']) && !error()) {
         if ($image->ValidateImage($array['tmp_name'], $ext)) {
             $file = BASEDIR . '/files/thumbs/' . $_POST['file_name'] . '.' . $ext;
             $bfile = BASEDIR . '/files/thumbs/' . $_POST['file_name'] . '.-big.' . $ext;
             if (!file_exists($file)) {
                 move_uploaded_file($array['tmp_name'], $file);
                 $image->CreateThumb($file, $bfile, config('big_thumb_width'), $ext, config('big_thumb_height'), false);
                 $image->CreateThumb($file, $file, THUMB_WIDTH, $ext, THUMB_HEIGHT, false);
             }
         } else {
             e(lang('vdo_thumb_up_err'));
         }
     } else {
         return true;
     }
 }
开发者ID:yukisky,项目名称:clipbucket,代码行数:23,代码来源:embed_video_mod.php


示例17: strtolower

				<td width="40">번호</td>
				<td>파일명</td>
				<td width="70">소유자</td>
				<td width="70">퍼미션</td>
				<td width="70">용량</td>
				<td width="70">크기(px)</td>
				<td width="55">&nbsp;</td>
			</tr>
			<?php 
    $j = 0;
    for ($i = ($p - 1) * $recnum; $i <= ($p - 1) * $recnum + $recnum - 1; $i++) {
        if ($files[$i]) {
            $j++;
            ?>
			<?php 
            $file_ext = strtolower(getExt($files[$i]));
            ?>
			<?php 
            $file_ext = strlen($file_ext) < 5 ? $file_ext : 'txt';
            ?>
			<?php 
            $IM = array();
            if (strstr('jpeg,jpg,gif,png,swf', strtolower($file_ext))) {
                $IM = getimagesize($tdir . $files[$i]);
            }
            ?>

			<tr class="loop">
				<td><input type="checkbox" name="members[]" value="<?php 
            echo getKRtoUTF($files[$i]);
            ?>
开发者ID:hoya0704,项目名称:trevia.co.kr,代码行数:31,代码来源:main.php


示例18: uploadFile

/**
 * 上传文件
 * @param array $fileInfo
 * @param string $path
 * @param array $allowExt
 * @param int $maxSize
 * @return string
 */
function uploadFile($fileInfo, $path, $allowExt = array("gif", "jpeg", "jpg", "png", "txt", "doc"), $maxSize = 10485760)
{
    //判断错误号
    if ($fileInfo['error'] == UPLOAD_ERR_OK) {
        //文件是否是通过HTTP POST方式上传上来的
        if (is_uploaded_file($fileInfo['tmp_name'])) {
            //上传文件的文件名,只允许上传jpeg|jpg、png、gif、txt的文件
            //$allowExt=array("gif","jpeg","jpg","png","txt");
            $ext = getExt($fileInfo['name']);
            //取出扩展名
            $uniqid = getUniqidName();
            //产生一个唯一的文件
            $destination = $path . "/" . pathinfo($fileInfo['name'], PATHINFO_FILENAME) . "_" . $uniqid . "." . $ext;
            if (in_array($ext, $allowExt)) {
                if ($fileInfo['size'] <= $maxSize) {
                    if (move_uploaded_file($fileInfo['tmp_name'], $destination)) {
                        $mes = "文件上传成功";
                    } else {
                        $mes = "文件移动失败";
                    }
                } else {
                    $mes = "文件过大";
                }
            } else {
                $mes = "非法文件类型";
            }
        } else {
            $mes = "文件不是通过HTTP POST方式上传上来的";
        }
    } else {
        switch ($fileInfo['error']) {
            case 1:
                $mes = "超过了配置文件的大小";
                break;
            case 2:
                $mes = "超过了表单允许接收数据的大小";
                break;
            case 3:
                $mes = "文件部分被上传";
                break;
            case 4:
                $mes = "没有文件被上传";
                break;
        }
    }
    return $mes;
}
开发者ID:Jeffery-Cai,项目名称:fileManager,代码行数:55,代码来源:file.func.php


示例19: upload_error

                upload_error("File has no name.");
                exit(0);
            }
        }
    }
}
//Check file size
$file_size = @filesize($_FILES['Filedata']["tmp_name"]);
if (!$file_size || $file_size > $max_file_size_in_bytes) {
    upload_error("File exceeds the maximum allowed size");
    exit(0);
}
//Checking file type
$types_array = preg_replace('/,/', ' ', $types);
$types_array = explode(' ', $types_array);
$file_ext = strtolower(getExt($_FILES['Filedata']['name']));
if (!in_array($file_ext, $types_array)) {
    upload_error("Invalid file extension");
    exit(0);
}
move_uploaded_file($tempFile, $targetFile);
$Upload->add_conversion_queue($targetFileName, $file_directory);
//exec(php_path()." -q ".BASEDIR."/actions/video_convert.php &> /dev/null &");
if (stristr(PHP_OS, 'WIN')) {
    exec(php_path() . " -q " . BASEDIR . "/actions/video_convert.php {$targetFileName}");
} else {
    exec(php_path() . " -q " . BASEDIR . "/actions/video_convert.php {$targetFileName} &> /dev/null &");
}
$status_array['success'] = 'yes';
$status_array['file_name'] = $file_name;
echo json_encode($status_array);
开发者ID:Coding110,项目名称:cbvideo,代码行数:31,代码来源:file_uploader.php


示例20: uploadFiles

/**
 * 多文件上传
 *
 */
function uploadFiles($allowExt = array("gif", "jpeg", "jpg", "png", "wbmp"), $maxSize = 2097152, $imgFlag = true, $path = "uploads")
{
    // 检查文件夹
    if (!file_exists($path)) {
        mkdir($path, 0777, true);
    }
    $i = 0;
    $files = @buildInfo();
    if (!isset($files)) {
        exit("请不要上传不能被识别的文件,错误:\$" . "_" . "FILES" . " is empty");
    }
    foreach ($files as $file) {
        $tmp_name = $file['tmp_name'];
        $error = $file['error'];
        $size = $file['size'];
        $type = $file['type'];
        $name = $file['name'];
        if ($error == UPLOAD_ERR_OK) {
            $ext = getExt($name);
            // 检查文件拓展名
            if (!in_array($ext, $allowExt)) {
                exit("非法文件类型");
            }
            // 检查大小
            if ($size > $maxSize) {
                exit("文件过大");
            }
            // 检查是否是使用POST HTTP方式上传
            if (!is_uploaded_file($tmp_name)) {
                exit("不是使用POST HTTP方式上传");
            }
            // 检查是否是图片类型
            if ($imgFlag && !getimagesize($tmp_name)) {
                exit("不是真正的图片类型");
            }
            $uniName = getUniName() . '.' . $ext;
            $destination = $path . "/" . $uniName;
            if (move_uploaded_file($tmp_name, $destination)) {
                $file['name'] = $uniName;
                unset($file['tmp_name'], $file['error'], $file['size'], $file['type']);
                $uploadedFiles[$i] = $file;
                $i++;
            }
        } else {
            switch ($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
                    break;
            }
            echo $mes;
        }
    }
    return $uploadedFiles;
}
开发者ID:hiden2,项目名称:shopImooc-1,代码行数:83,代码来源:upload.func.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP getExtendedAnswer函数代码示例发布时间:2022-05-15
下一篇:
PHP getExpoCurrent函数代码示例发布时间: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