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

PHP get_extension函数代码示例

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

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



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

示例1: load

 function load()
 {
     if ($this->exists() == true) {
         $this->import();
     } else {
         require_once 'classes/class.geshi.php';
         $this->data = array();
         $source = 'classes/geshi/';
         $d = dir($source);
         while (false !== ($entry = $d->read())) {
             if (get_extension($entry) == 'php' && !is_dir($source . $entry)) {
                 include_once $source . $entry;
                 if (!isset($language_data['NO_INDEX'])) {
                     $short = str_replace('.php', '', $entry);
                     $this->data[$short]['file'] = $entry;
                     $this->data[$short]['name'] = $language_data['LANG_NAME'];
                     $this->data[$short]['short'] = $short;
                 }
             }
         }
         $d->close();
         asort($this->data);
         $this->export();
     }
 }
开发者ID:BackupTheBerlios,项目名称:viscacha-svn,代码行数:25,代码来源:syntaxhighlight.inc.php


示例2: SaveHTTPFile

function SaveHTTPFile($fFileHTTPPath, $fFileSavePath, $fFileSaveName)
{
    //记录程序开始的时间
    $BeginTime = getmicrotime();
    //取得文件名
    $fFileSaveName = $fFileSavePath . "/" . $fFileSaveName;
    make_dir(dirname($fFileSaveName));
    //取得文件的内容
    ob_start();
    readfile($fFileHTTPPath);
    $img = ob_get_contents();
    ob_end_clean();
    //$size = strlen($img);
    //保存到本地
    $fp2 = @fopen($fFileSaveName, "a");
    fwrite($fp2, $img);
    fclose($fp2);
    /*加水印代码*/
    require_once ROOT_PATH . 'includes/cls_image.php';
    $ext = get_extension($fFileSaveName);
    $fFileSaveName = convert_GIF_to_JPG($fFileSaveName);
    if (CopyFiles($fFileSaveName)) {
        $image = new cls_image();
        $image->add_watermark($fFileSaveName, '', '../../../../' . $GLOBALS['waterMark']['watermark'], $GLOBALS['waterMark']['watermark_place'], $GLOBALS['waterMark']['watermark_alpha']);
    }
    if ($ext == 'gif' || $ext == '.gif') {
        back_JPG_to_GIF($fFileSaveName);
    }
    /*加水印代码--end*/
    //记录程序运行结束的时间
    $EndTime = getmicrotime();
    //返回运行时间
    return $EndTime - $BeginTime;
}
开发者ID:norain2050,项目名称:benhu,代码行数:34,代码来源:ServerXMLHTTP.php


示例3: export_template_list

function export_template_list($path, $d = 0)
{
    if (substr($path, strlen($path) - 1) != '/') {
        $path .= '/';
    }
    $dirlist = array();
    if ($handle = opendir($path)) {
        while (false !== ($file = readdir($handle))) {
            if ($file != '.' && $file != '..') {
                $file = $path . $file;
                if (!is_dir($file)) {
                    $extension = get_extension($path);
                    if (stripos($extension, 'bak') === false) {
                        $dirlist[] = $file;
                    }
                } elseif ($d >= 0) {
                    $result = export_template_list($file . '/', $d + 1);
                    $dirlist = array_merge($dirlist, $result);
                }
            }
        }
        closedir($handle);
    }
    if ($d == 0) {
        natcasesort($dirlist);
    }
    return $dirlist;
}
开发者ID:BackupTheBerlios,项目名称:viscacha-svn,代码行数:28,代码来源:designs.php


示例4: upload

function upload()
{
    $msg = 9;
    $con = mysqli_connect('localhost', 'shibli', 'shibli');
    mysqli_select_db($con, 'piclib');
    $imaget = mysqli_real_escape_string($con, $_FILES["userfile"]["type"]);
    $f = substr($imaget, 0, 5);
    if ($f == "image") {
        if (is_uploaded_file($_FILES['userfile']['tmp_name'])) {
            header("location: http://localhost:63342/VideoLibraryApp/views/fun.php");
        }
        $imgData = addslashes(file_get_contents($_FILES['userfile']['tmp_name']));
        $ext = get_extension($_FILES['userfile']['name']);
        $query2 = " Select max(imageID) from imgdata;";
        $result2 = mysqli_query($con, $query2);
        $row2 = mysqli_fetch_row($result2);
        $r = $row2[0] + 1;
        $sql = "INSERT INTO imgdata values({$r},'{$ext}','{$_POST['imageName']}','{$_POST['user']}','{$imgData}')";
        mysqli_query($con, $sql) or die("Error in Query: " . mysqli_error($con));
        header("location: http://localhost:63342/VideoLibraryApp/views/displayLogged.php");
    } else {
        //$finfo = finfo_open(FILEINFO_MIME_TYPE);
        //finfo_file($finfo, $_FILES['userfile']['tmp_name']);
        header("location: http://localhost:63342/VideoLibraryApp/views/main.css");
    }
    return $msg;
}
开发者ID:shiblibaig,项目名称:Photo-Library,代码行数:27,代码来源:uploadPics.php


示例5: upload_data

function upload_data()
{
    $msg = "";
    $filename = $_FILES["file"]["name"];
    //文件名
    //echo get_extension($filename);exit;
    if (get_extension($filename) == "csv") {
        if ($_FILES["file"]["error"] > 0) {
            $msg = "上传错误: " . $_FILES["file"]["error"];
        } else {
            if (file_exists("data/" . $_FILES["file"]["name"])) {
                $msg = $_FILES["file"]["name"] . " 已经存在,请查看data文件下是否存在您的数据文件. ";
            } else {
                move_uploaded_file($_FILES["file"]["tmp_name"], "data/" . $_FILES["file"]["name"]);
                if (file_exists("data/" . $_FILES["file"]["name"])) {
                    $msg = "上传成功!文件已经保存在了 " . "data/" . $_FILES["file"]["name"] . "接下来您可以导入本次打卡记录了。";
                } else {
                    $msg = "上传失败,因为目录权限被拒绝,请手动上传。";
                }
            }
        }
    } else {
        $msg = "文件格式错误";
    }
    return $msg;
}
开发者ID:sdgdsffdsfff,项目名称:duty,代码行数:26,代码来源:upload.php


示例6: convert_data

 function convert_data($data)
 {
     global $db, $import_session, $mybb, $error_notice, $insert_data;
     static $field_info;
     if (!isset($field_info)) {
         // Get columns so we avoid any 'unknown column' errors
         $field_info = $db->show_fields_from("attachments");
     }
     $insert_data = array();
     foreach ($field_info as $key => $field) {
         if ($field['Extra'] == 'auto_increment') {
             if ($db->type != "sqlite") {
                 $insert_data[$field['Field']] = '';
             }
             continue;
         }
         if (isset($data[$field['Field']])) {
             $insert_data[$field['Field']] = $data[$field['Field']];
         }
     }
     // MyBB 1.6 values
     $insert_data['import_aid'] = $data['aid'];
     $insert_data['pid'] = $this->get_import->pid($data['pid']);
     $insert_data['uid'] = $this->get_import->uid($data['uid']);
     $attachname_array = explode('_', str_replace('.attach', '', $data['attachname']));
     $insert_data['attachname'] = 'post_' . $this->get_import->uid($attachname_array[1]) . '_' . $attachname_array[2] . '.attach';
     if ($data['thumbnail']) {
         $ext = get_extension($data['thumbnail']);
         $insert_data['thumbnail'] = str_replace(".attach", "_thumb.{$ext}", $insert_data['attachname']);
     }
     return $insert_data;
 }
开发者ID:dgrp,项目名称:merge-system,代码行数:32,代码来源:attachments.php


示例7: get_bak_file

/**
 * returns bak file for restore
 * @param string
 */
function get_bak_file($file)
{
    if (get_extension($file) == 'php') {
        return substr_replace($file, '.bak', strrpos($file, '.'), 0);
    } else {
        return $file . '.bak';
    }
}
开发者ID:HassenLin,项目名称:piwigo_utf8filename,代码行数:12,代码来源:functions.inc.php


示例8: data_uri

function data_uri($file)
{
    $type = get_extension($file);
    $mime = 'image/' . $type;
    $contents = file_get_contents($file);
    $base64 = base64_encode($contents);
    return 'data:' . $mime . ';base64,' . $base64;
}
开发者ID:Covert-Inferno,项目名称:callme,代码行数:8,代码来源:login.php


示例9: save_external_image

 public function save_external_image($url = '', $path = '')
 {
     if (empty($url)) {
         return;
     }
     $ch = curl_init($url);
     curl_setopt($ch, CURLOPT_HEADER, 0);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
     $err = curl_error($ch);
     if (empty($err)) {
         $rawdata = curl_exec($ch);
     }
     curl_close($ch);
     if ($rawdata) {
         $ext = get_extension($path);
         $upload_path = './uploads/editor/';
         if (is_dir($upload_path) == false) {
             mkdir($upload_path, 0707);
             $file = $upload_path . 'index.php';
             $f = @fopen($file, 'w');
             @fwrite($f, '');
             @fclose($f);
             @chmod($file, 0644);
         }
         $upload_path .= cdate('Y') . '/';
         if (is_dir($upload_path) === false) {
             mkdir($upload_path, 0707);
             $file = $upload_path . 'index.php';
             $f = @fopen($file, 'w');
             @fwrite($f, '');
             @fclose($f);
             @chmod($file, 0644);
         }
         $upload_path .= cdate('m') . '/';
         if (is_dir($upload_path) === false) {
             mkdir($upload_path, 0707);
             $file = $upload_path . 'index.php';
             $f = @fopen($file, 'w');
             @fwrite($f, '');
             @fclose($f);
             @chmod($file, 0644);
         }
         list($usec, $sec) = explode(' ', microtime());
         $file_name = md5(uniqid(mt_rand())) . '_' . str_replace('.', '', $sec . $usec) . '.' . $ext;
         $save_dir = $upload_path . $file_name;
         $save_url = site_url('uploads/editor/' . cdate('Y') . '/' . cdate('m') . '/' . $file_name);
         $fp = fopen($save_dir, 'w');
         fwrite($fp, $rawdata);
         fclose($fp);
         if (file_exists($save_dir)) {
             return $save_url;
         }
     }
     return;
 }
开发者ID:smboy86,项目名称:zzing,代码行数:56,代码来源:Imagelib.php


示例10: __autoload

function __autoload($class)
{
    // $class = strtolower($class);
    // $class = str_replace('A\\',DIRECTORY_SEPARATOR,$class);
    $name = $class . '.class.php';
    // echo $name;
    get_extension($name);
    get_exist($name);
    require_once $name;
}
开发者ID:yyangzhou,项目名称:yangzhou,代码行数:10,代码来源:autoload.php


示例11: show_image

function show_image($image)
{
    header('Content-type: image/' . get_extension($image));
    $handle = fopen($image, "rb");
    while (!feof($handle)) {
        $buffer = fgets($handle, 4096);
        echo $buffer;
    }
    fclose($handle);
}
开发者ID:shifter,项目名称:ospap,代码行数:10,代码来源:picture.php


示例12: getFileType

function getFileType($image_data)
{
    $f = finfo_open();
    $mime_type = finfo_buffer($f, $image_data, FILEINFO_MIME_TYPE);
    $ext = get_extension($mime_type);
    if ($ext === false) {
        error("Unsupported filetype: " . $mime_type);
    }
    return $ext;
}
开发者ID:shadowbeam,项目名称:img-srch,代码行数:10,代码来源:file-upload.php


示例13: verif_image

function verif_image($tabFile)
{
    $ret = _UPLOAD_NO_ERROR;
    $file_name = $tabFile["name"];
    $extension = get_extension($file_name);
    if (!in_array($extension, array(_UPLOAD_EXTENSION_JPG, _UPLOAD_EXTENSION_PNG, _UPLOAD_EXTENSION_GIF))) {
        $ret = _UPLOAD_TYPE_ERROR;
    }
    return $ret;
}
开发者ID:PetiLabo,项目名称:PetiLabo,代码行数:10,代码来源:upload_image.php


示例14: jet_Upload

/**
 * @param string $name
 * @param string $type
 * @return bool
 */
function jet_Upload($name = 'random', $type = 'image')
{
    if ($type and !file_exists(ROOT . '/uploads/' . $type)) {
        mkdir(ROOT . '/uploads/' . $type);
    }
    $f = array_keys($_FILES)[0];
    $ext = get_extension($_FILES[$f]['name']);
    $save_path = $type ? ROOT . '/uploads/' . $type . '/' : ROOT . 'uploads/';
    $save_name = $name ? $name . '.' . $ext : jetRandString(12) . '.' . $ext;
    return move_uploaded_file($_FILES[$f]["tmp_name"], $save_path . $save_name) || false;
}
开发者ID:Jaggle,项目名称:JetPHP,代码行数:16,代码来源:functions.php


示例15: deal_upload_image

function deal_upload_image($fileInfo, $allowExt = array("gif", "jpeg", "jpg", "png", "wbmp"), $maxSize = 1512000, $imgFlag = true)
{
    if ($fileInfo['error'] == 0) {
        //UPLOAD_ERR_OK
        $f_ext = get_extension($fileInfo['name']);
        if (!in_array($f_ext, $allowExt)) {
            return $mes = '非法文件类型';
        }
        if ($fileInfo['size'] > $maxSize) {
            return $mes = '文件大小超过上限';
        }
        if ($imgFlag) {
            $info = getimagesize($fileInfo['tmp_name']);
            if (!$info) {
                return $mes = '不是真实的图片类型';
            }
        }
        return true;
    } else {
        switch ($fileInfo['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;
        }
        return $mes;
    }
}
开发者ID:rayshuai,项目名称:Myfunctions,代码行数:52,代码来源:deal_upload_image.php


示例16: upload

function upload()
{
    $maxsize = 10000000;
    //set to approx 10 MB
    //check associated error code
    if ($_FILES['userfile']['error'] == UPLOAD_ERR_OK) {
        //check whether file is uploaded with HTTP POST
        if (is_uploaded_file($_FILES['userfile']['tmp_name'])) {
            //checks size of uploaded image on server side
            if ($_FILES['userfile']['size'] < $maxsize) {
                //checks whether uploaded file is of image type
                //if(strpos(mime_content_type($_FILES['userfile']['tmp_name']),"image")===0) {
                $finfo = finfo_open(FILEINFO_MIME_TYPE);
                if (strpos(finfo_file($finfo, $_FILES['userfile']['tmp_name']), "image") === 0) {
                    // prepare the image for insertion
                    $imgData = addslashes(file_get_contents($_FILES['userfile']['tmp_name']));
                    // put the image in the db...
                    // database connection
                    $con = mysqli_connect('localhost', 'shibli', 'shibli') or die(mysqli_error($con));
                    // select the db
                    mysqli_select_db($con, 'piclib') or die("Unable to select db" . mysqli_error($con));
                    // our sql query
                    $ext = get_extension($_FILES['userfile']['name']);
                    $query2 = " Select max(imageID) from imgdata;";
                    $result2 = mysqli_query($con, $query2);
                    $row2 = mysqli_fetch_row($result2);
                    $r = $row2[0] + 1;
                    $sql = "INSERT INTO imgdata values({$r},'{$ext}','{$_POST['imageName']}','{$_POST['user']}','{$imgData}')";
                    header('location: http://localhost:63342/VideoLibraryApp/views/displayLogged.php');
                    // insert the image
                    mysqli_query($con, $sql) or die("Error in Query: " . mysqli_error($con));
                    $msg = '<p>Image successfully saved in database with id =' . mysqli_insert_id($con) . ' </p>';
                } else {
                    $msg = "<p>Uploaded file is not an image.</p>";
                }
            } else {
                // if the file is not less than the maximum allowed, print an error
                $msg = '<div>File exceeds the Maximum File limit</div>
                <div>Maximum File limit is ' . $maxsize . ' bytes</div>
                <div>File ' . $_FILES['userfile']['name'] . ' is ' . $_FILES['userfile']['size'] . ' bytes</div><hr />';
            }
        } else {
            $msg = "File not uploaded successfully.";
        }
    } else {
        $msg = file_upload_error_message($_FILES['userfile']['error']);
    }
    return $msg;
}
开发者ID:shiblibaig,项目名称:Photo-Library,代码行数:49,代码来源:originsert.php


示例17: _do_upload

 function _do_upload()
 {
     $config['upload_path'] = './assets/logo/';
     $config['overwrite'] = TRUE;
     $config['file_name'] = 'logo';
     $config['allowed_types'] = 'jpg|jpeg|png|bmp';
     $this->load->library('upload', $config);
     $ext = @get_extension($_FILES['logo']["name"]);
     if ($this->upload->do_upload('logo')) {
         $resize = array('width' => 100, 'height' => 100, 'quality' => '100%', 'create_thumb' => false, 'source_image' => './assets/logo/' . $config['file_name'] . $ext);
         $this->load->library('image_lib', $resize);
         //$this->image_lib->initialize();
         $this->image_lib->resize();
         $this->image_lib->clear();
         return 'logo' . $ext;
     }
     return null;
 }
开发者ID:agusnu,项目名称:surat,代码行数:18,代码来源:instansi.php


示例18: replace_phonegap_tag

function replace_phonegap_tag($path)
{
    $filelist = my_scandir($path);
    foreach ($filelist as $file) {
        if (get_extension($file) == "html") {
            $path_prefix = "";
            echo $file . "\n";
            $wwwpos = strpos($file, "www/");
            $filename = substr($file, $wwwpos);
            for ($i = 0; $i < substr_count($filename, "/") - 1; $i++) {
                $path_prefix .= "../";
            }
            $content = file_get_contents($file);
            $new_content = preg_replace("/<phonegap>.*<\\/phonegap>/is", "<script type='text/javascript' charset='utf-8' src='" . $path_prefix . "phonegap.js'></script>", $content);
            file_put_contents($file, $new_content);
        }
    }
}
开发者ID:sdgdsffdsfff,项目名称:PhoneGap-Packager,代码行数:18,代码来源:phonegap_tag_replace.php


示例19: saveFile

function saveFile($postFileField)
{
    //get location where file will be saved
    $path = getenv("DOCUMENT_ROOT") . '/admin/reseller_locator/products/product_images/';
    $file_temp = $_FILES[$postFileField]['tmp_name'];
    $file_name = prep_filename($_FILES[$postFileField]['name']);
    $file_ext = get_extension($_FILES[$postFileField]['name']);
    $newf_name = set_filename($path, $file_name, $file_ext);
    $file_size = round($_FILES[$postFileField]['size'] / 1024, 2);
    $targetFile = str_replace('//', '/', $path) . $newf_name;
    //save the file
    move_uploaded_file($file_temp, $targetFile);
    if ($GLOBALS['debug']) {
        echo 'file ' . $file_name . ' was saved.';
    }
    //save file permissions
    chmod($targetFile, 0777);
    //return $file_name; //to be saved in the db
    return $newf_name;
    //to be saved in the db
}
开发者ID:ruebenramirez,项目名称:Contact-Locator,代码行数:21,代码来源:files.php


示例20: make_thumb

function make_thumb($img_name, $filename, $new_w, $new_h)
{
    $ext = get_extension($img_name);
    if (!strcmp("jpg", $ext) || !strcmp("jpeg", $ext)) {
        $src_img = imagecreatefromjpeg($img_name);
    }
    if (!strcmp("png", $ext)) {
        $src_img = imagecreatefrompng($img_name);
    }
    if (!strcmp("gif", $ext)) {
        $src_img = imagecreatefrompng($img_name);
    }
    $old_x = imageSX($src_img);
    $old_y = imageSY($src_img);
    $ratio1 = $old_x / $new_w;
    $ratio2 = $old_y / $new_h;
    if ($ratio1 > $ratio2) {
        $thumb_w = $new_w;
        $thumb_h = $old_y / $ratio1;
    } else {
        $thumb_h = $new_h;
        $thumb_w = $old_x / $ratio2;
    }
    $dst_img = ImageCreateTrueColor($thumb_w, $thumb_h);
    imagealphablending($dst_img, false);
    imagesavealpha($dst_img, true);
    imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $thumb_w, $thumb_h, $old_x, $old_y);
    if (!strcmp("png", $ext)) {
        imagepng($dst_img, $filename);
    }
    if (!strcmp("jpg", $ext) || !strcmp("jpeg", $ext)) {
        imagejpeg($dst_img, $filename, 100);
    }
    if (!strcmp("gif", $ext)) {
        imagegif($dst_img, $filename);
    }
    imagedestroy($dst_img);
    imagedestroy($src_img);
}
开发者ID:Covert-Inferno,项目名称:callme,代码行数:39,代码来源:upload.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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