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

PHP getExtension函数代码示例

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

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



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

示例1: url

 static function url($urls, $albumID = 0)
 {
     $error = false;
     # Parse
     $urls = str_replace(' ', '%20', $urls);
     $urls = explode(',', $urls);
     foreach ($urls as &$url) {
         # Verify extension
         $extension = getExtension($url);
         if (!in_array(strtolower($extension), Photo::$validExtensions, true)) {
             $error = true;
             continue;
         }
         # Verify image
         $type = @exif_imagetype($url);
         if (!in_array($type, Photo::$validTypes, true)) {
             $error = true;
             continue;
         }
         $pathinfo = pathinfo($url);
         $filename = $pathinfo['filename'] . '.' . $pathinfo['extension'];
         $tmp_name = LYCHEE_DATA . $filename;
         if (@copy($url, $tmp_name) === false) {
             $error = true;
         }
     }
     $import = Import::server($albumID, LYCHEE_DATA);
     if ($error === false && $import === true) {
         return true;
     } else {
         return false;
     }
 }
开发者ID:thejandroman,项目名称:Lychee,代码行数:33,代码来源:Import.php


示例2: validate_language_form

function validate_language_form($data)
{
    define("ICON_MAX_SIZE", "100");
    $error = '';
    if ($data['country'] == '' || empty($data['country'])) {
        $error .= "Country field required!!<br>";
    }
    if ($data['language'] == '' || empty($data['language'])) {
        $error .= "Language field required!!<br>";
    }
    if ($data['currency'] == '' || empty($data['currency'])) {
        $error .= "Currency field required!!<br>";
    }
    $filename = stripslashes($data['icon']['name']);
    if ($filename) {
        $extension = getExtension($filename);
        $extension = strtolower($extension);
        if ($extension != "jpg" && $extension != "jpeg" && $extension != "png" && $extension != "gif") {
            $error .= "Upload language icon unknown extension!!<br>";
        } else {
            $size = $data['icon']['size'];
            if ($size > ICON_MAX_SIZE * 1024) {
                $error .= "Upload language icon exceeded the size limit!!<br>";
            }
            list($width, $height) = getimagesize($data['icon']['tmp_name']);
            if ($width > 50 || $height > 50) {
                $error .= "Upload language icon size must 50 * 50!!<br>";
            }
        }
    } else {
        $error .= "Upload language icon field required!!<br>";
    }
    return $error;
}
开发者ID:beyondkeysystem,项目名称:testone,代码行数:34,代码来源:functions.php


示例3: hinzufuegen

function hinzufuegen($bildseite, $datenbank)
{
    if (hinzufuegenVariablenVorhanden()) {
        if ($extension = getExtension()) {
            // ZeigenAb wurde angegeben
            if (strtotime($_POST["zeigenAb"]) !== false) {
                // ZeigenBis wurde angegeben
                if (strtotime($_POST["zeigenBis"]) !== false) {
                    $bildseite->create($datenbank, $extension, $_POST["beschriftung"], $_POST["layout"], date("Y-m-d H:i:s", strtotime($_POST["zeigenAb"])), date("Y-m-d H:i:s", strtotime($_POST["zeigenBis"])));
                    // ZeigenBis wurde nicht angegeben
                } else {
                    $bildseite->create($datenbank, $extension, $_POST["beschriftung"], $_POST["layout"], date("Y-m-d H:i:s", strtotime($_POST["zeigenAb"])));
                }
                // ZeigenAb wurde nicht angegeben
            } else {
                $bildseite->create($datenbank, $extension, $_POST["beschriftung"], $_POST["layout"]);
            }
            dateiVerschieben($bildseite->id, $extension);
            zurueck();
        } else {
            echo "Datei wurde nicht erfolgreich hochgeladen :/";
        }
    } else {
        echo "Nicht alle oder ungültige Daten übertragen :/";
    }
}
开发者ID:emteg,项目名称:beamercontrol,代码行数:26,代码来源:bildseiteedit.php


示例4: boot

 /**
  * Bootstraps the application.
  *
  * This method is called after all services are registers
  * and should be used for "dynamic" configuration (whenever
  * a service must be requested).
  */
 public function boot(Application $app)
 {
     if (isset($app['translator'])) {
         $paths = $app['resources']->getPaths();
         $app['translator']->addLoader('yml', new TranslationLoader\YamlFileLoader());
         // Directory to look for translation file(s)
         $translationDir = $paths['apppath'] . '/resources/translations/' . $app['locale'];
         if (is_dir($translationDir)) {
             $iterator = new \DirectoryIterator($translationDir);
             /**
              * @var \SplFileInfo $fileInfo
              */
             foreach ($iterator as $fileInfo) {
                 if ($fileInfo->isFile() && getExtension($fileInfo->getFilename()) == "yml") {
                     $fnameParts = explode(".", $fileInfo->getFilename());
                     $domain = $fnameParts[0];
                     $app['translator']->addResource('yml', $fileInfo->getRealPath(), $app['locale'], $domain);
                 }
             }
         }
         // Load fallback for infos domain
         $infosfilename = dirname(dirname(dirname(__DIR__))) . '/resources/translations/en/infos.en.yml';
         if (is_readable($infosfilename)) {
             $app['translator']->addResource('yml', $infosfilename, 'en', 'infos');
         }
     }
 }
开发者ID:Hoplite-Software,项目名称:observatory,代码行数:34,代码来源:TranslationServiceProvider.php


示例5: findFilesHelper

function findFilesHelper($additional, &$files, $term = '', $extensions = array())
{
    $basefolder = __DIR__ . '/../../files/';
    $currentfolder = realpath($basefolder . '/' . $additional);
    $dir = dir($currentfolder);
    $ignored = array('.', '..', '.DS_Store', '.gitignore', '.htaccess');
    while (false !== ($entry = $dir->read())) {
        if (in_array($entry, $ignored) || substr($entry, 0, 2) == '._') {
            continue;
        }
        if (is_file($currentfolder . '/' . $entry) && is_readable($currentfolder . '/' . $entry)) {
            // Check for 'term'..
            if (!empty($term) && strpos(strtolower($currentfolder . '/' . $entry), $term) === false) {
                continue;
                // skip this one..
            }
            // Check for correct extensions..
            if (!empty($extensions) && !in_array(getExtension($entry), $extensions)) {
                continue;
                // Skip files without correct extension..
            }
            if (!empty($additional)) {
                $filename = $additional . '/' . $entry;
            } else {
                $filename = $entry;
            }
            $files[] = $filename;
        }
        if (is_dir($currentfolder . '/' . $entry)) {
            findFilesHelper($additional . '/' . $entry, $files, $term, $extensions);
        }
    }
    $dir->close();
}
开发者ID:LeonB,项目名称:site,代码行数:34,代码来源:lib.php


示例6: resizeImage

function resizeImage($filename, $newfilename, $max_width = '', $max_height = '', $withSampling = true)
{
    // if($newfilename=="")
    //     $newfilename=$filename;
    // Get new sizes
    list($width, $height) = getimagesize($filename);
    if ($max_width == '' && $max_height == '') {
        exit("You must set a max height or width");
    }
    if ($max_width != '') {
        $percent = $max_width / $width;
    } else {
        if ($max_height != '') {
            $percent = $max_height / $height;
        }
    }
    //-- dont resize if the width of the image is smaller or equal than the new size.
    // if($width<=$max_width)
    //     $max_width=$width;
    // $percent = $max_width/$width;
    $newwidth = $width * $percent;
    $newheight = $height * $percent;
    // if($max_height=='') {
    // } else
    // $newheight = $max_height;
    // Load
    $thumb = imagecreatetruecolor($newwidth, $newheight);
    $ext = strtolower(getExtension($filename));
    // print $ext;
    // exit();
    if ($ext == 'jpg' || $ext == 'jpeg') {
        $source = imagecreatefromjpeg($filename);
    } else {
        if ($ext == 'gif') {
            $source = imagecreatefromgif($filename);
        } else {
            if ($ext == 'png') {
                $source = imagecreatefrompng($filename);
            }
        }
    }
    // Resize
    if ($withSampling) {
        imagecopyresampled($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
    } else {
        imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
    }
    // imagedestroy($thumb);
    // Output
    if ($ext == 'jpg' || $ext == 'jpeg') {
        return imagejpeg($thumb, $newfilename);
    }
    if ($ext == 'gif') {
        return imagegif($thumb, $newfilename);
    }
    if ($ext == 'png') {
        return imagepng($thumb, $newfilename);
    }
}
开发者ID:artlung,项目名称:ArtLung-Util,代码行数:59,代码来源:inc.functions.php


示例7: changeFileNameImage

function changeFileNameImage($filename)
{
    $file = getFilename($filename);
    $str = strtotime(date('Y-m-d H:i:s'));
    $fileNameAfter = $file . '-' . $str;
    $extension = getExtension($filename);
    return $fileNameAfter . '.' . $extension;
}
开发者ID:trantung,项目名称:company,代码行数:8,代码来源:Function.php


示例8: check_upload_extension

function check_upload_extension($filename,$allow_list){
	$sExtension	= getExtension($filename);
	$allow_arr	= explode(",", $allow_list);
	$pass = 0;
	for($i=0; $i<count($allow_arr); $i++){
		if($sExtension == $allow_arr[$i]) $pass = 1;
	}
	return $pass;
}
开发者ID:nhphong0104,项目名称:thietkeweb360,代码行数:9,代码来源:file_functions.php


示例9: post_image

function post_image()
{
    //$errors=0;
    //checks if the form has been submitted
    if (isset($_POST['Submit'])) {
        //reads the name of the file the user submitted for uploading
        $image = $_FILES['image']['name'];
        //echo $image;
        //if it is not empty
        if ($image) {
            //get the original name of the file from the clients machine
            $filename = stripslashes($_FILES['image']['name']);
            //get the extension of the file in a lower case format
            $extension = getExtension($filename);
            $extension = strtolower($extension);
            //if it is not a known extension, we will suppose it is an error and will not  upload the file,
            //otherwise we will do more tests
            //echo $filename;
            //echo $extension;
            if ($extension != "jpg" && $extension != "jpeg" && $extension != "png" && $extension != "gif") {
                //print error message
                echo '<h1>Unknown extension!</h1>';
                //$errors=1;
                return false;
            } else {
                //get the size of the image in bytes
                //$_FILES['image']['tmp_name'] is the temporary filename of the file
                //in which the uploaded file was stored on the server
                $size = filesize($_FILES['image']['tmp_name']);
                //compare the size with the maxim size we defined and print error if bigger
                if ($size > MAX_SIZE * 1024) {
                    echo '<h1>File over size limit (1.5 mb).</h1>';
                    $errors = 1;
                    return false;
                }
                $image_name = time() . make_random() . '.' . $extension;
                //echo "image name var ".$image_name;
                //the new name will be containing the full path where will be stored (images folder)
                $newname = "img_db/" . $image_name;
                //we verify if the image has been uploaded, and print error instead
                $copied = copy($_FILES['image']['tmp_name'], $newname);
                if (!$copied) {
                    echo '<h1>Copy unsuccessfull!</h1>';
                    $errors = 1;
                    return false;
                } else {
                    //echo "accepted";
                    $GLOBALS['newname'] = $newname;
                    return true;
                }
            }
            //else for extension known.
        }
        //make sure image is not empty
    }
    //recheck is POST isset
}
开发者ID:nainapjj,项目名称:waanoo,代码行数:57,代码来源:imgform.php


示例10: upload

function upload($file, $allow = array('gif', 'png', 'jpeg', 'jpg'))
{
    //1.对$file进行判断,如果不是数组就不存在上传文件
    if (!is_array($file)) {
        return array(false, '当前不是上传的文件信息!');
    }
    //2. 判断文件是否上传成功
    //定义一个错误字符串
    $errorinfo = '';
    switch ($file['error']) {
        case 1:
            $errorinfo = '文件大小超过限制,最大上传大小为' . ini_get('upload_max_filesize');
            break;
        case 2:
            $errorinfo = '文件超过浏览器允许大小';
            break;
        case 3:
            $errorinfo = '文件只上传成功一部分';
            break;
        case 4:
            $errorinfo = '没有选中要上传的文件';
            break;
        case 6:
            $errorinfo = '找不到服务器临时目录';
            break;
        case 7:
            $errorinfo = '文件上传路径不可写';
            break;
    }
    if ($errorinfo) {
        return array(false, $errorinfo);
    }
    //3.判断文件类型
    $extension = getExtension($file['name']);
    //3.1 判断文件后缀是否存在
    if (!$extension) {
        //文件后缀名不存在
        return array(false, '当前文件没有后缀名!');
    }
    //3.2 当前文件是否允许上传
    if (!in_array($extension, $allow)) {
        return array(false, '当前文件类型不允许上传!');
    }
    //4.上传文件
    //4.1重命名文件:获取一个随机的文件名字
    $filename = getRanomFilename();
    //拼凑问价全名
    $filename .= '.' . $extension;
    //4.2移动文件
    if (!@move_uploaded_file($file['tmp_name'], $filename)) {
        //写错误日志
        return array(false, '文件上传失败');
    } else {
        return getcwd() . '\\' . $filename;
    }
}
开发者ID:lushizijizoude,项目名称:phpstarty,代码行数:56,代码来源:upload.php


示例11: generateThumbnail

 static function generateThumbnail($item)
 {
     $stats = self::generateStats($item['ups'], $item['favs'], $item['downs'], $item['safety']);
     $extension = getExtension($item['filename']);
     if ($extension == 'webm') {
         $item['filename'] .= '.png';
         $extension = 'png';
     }
     return intermix(self::$code, [$item['media_ID'], $item['filename'], $extension, $stats]);
 }
开发者ID:BourgondAries,项目名称:e622,代码行数:10,代码来源:Thumbnail.php


示例12: allowedUpload

 /**
  * Checks if a given file is acceptable for upload.
  */
 public function allowedUpload($originalFilename)
 {
     // no UNIX-hidden files
     if ($originalFilename[0] === '.') {
         return false;
     }
     // only whitelisted extensions
     $extension = strtolower(getExtension($originalFilename));
     $allowedExtensions = $this->getAllowedUploadExtensions();
     return in_array($extension, $allowedExtensions);
 }
开发者ID:LeonB,项目名称:site,代码行数:14,代码来源:FilePermissions.php


示例13: url

 public function url($urls, $albumID = 0)
 {
     # Check dependencies
     self::dependencies(isset($this->database, $urls));
     # Call plugins
     $this->plugins(__METHOD__, 0, func_get_args());
     $error = false;
     # Parse URLs
     $urls = str_replace(' ', '%20', $urls);
     $urls = explode(',', $urls);
     foreach ($urls as &$url) {
         # Validate photo type and extension even when $this->photo (=> $photo->add) will do the same.
         # This prevents us from downloading invalid photos.
         # Verify extension
         $extension = getExtension($url);
         if (!in_array(strtolower($extension), Photo::$validExtensions, true)) {
             $error = true;
             Log::error($this->database, __METHOD__, __LINE__, 'Photo format not supported (' . $url . ')');
             continue;
         }
         # Verify image
         $type = @exif_imagetype($url);
         if (!in_array($type, Photo::$validTypes, true)) {
             $error = true;
             Log::error($this->database, __METHOD__, __LINE__, 'Photo type not supported (' . $url . ')');
             continue;
         }
         $pathinfo = pathinfo($url);
         $filename = $pathinfo['filename'] . '.' . $pathinfo['extension'];
         $tmp_name = LYCHEE_DATA . $filename;
         if (@copy($url, $tmp_name) === false) {
             $error = true;
             Log::error($this->database, __METHOD__, __LINE__, 'Could not copy file (' . $tmp_name . ') to temp-folder (' . $tmp_name . ')');
             continue;
         }
         # Import photo
         if (!$this->photo($tmp_name, $albumID)) {
             $error = true;
             Log::error($this->database, __METHOD__, __LINE__, 'Could not import file: ' . $tmp_name);
             continue;
         }
     }
     # Call plugins
     $this->plugins(__METHOD__, 1, func_get_args());
     if ($error === false) {
         return true;
     }
     return false;
 }
开发者ID:gautamkrishnar,项目名称:Lychee,代码行数:49,代码来源:Import.php


示例14: getErrors

 public function getErrors($postarr = array())
 {
     //Получение ошибок при регистрации
     $this->name = $postarr['name'];
     $this->surname = $postarr['surname'];
     $this->email = $postarr['email'];
     $this->login = $postarr['login'];
     $this->password = $postarr['password'];
     $this->confirmpass = $postarr['confirmpass'];
     $this->age = $postarr['age'];
     $this->filename = $postarr['filename'];
     $this->filesize = $postarr['filesize'];
     if (!empty($this->filename)) {
         //проверяем расширение файла
         function getExtension($filename)
         {
             return end(explode(".", $filename));
         }
         $extension = getExtension($this->filename);
         //Проверка, существует ли пользователь с таким логином
     }
     $errors = array();
     if (empty($this->login)) {
         array_push($errors, "Заполните поле логин");
     } elseif (strlen($this->login) < 3) {
         array_push($errors, "Логин слишком короткий. Логин должен быть длиннее 3 символов");
     } elseif (empty($this->password)) {
         array_push($errors, "Заполните поле пароль");
     } elseif (empty($this->confirmpass)) {
         array_push($errors, "Заполните поле подтверждение пароля");
     } elseif (empty($this->email)) {
         array_push($errors, "Заполните поле Email");
     } elseif ($this->password != $this->confirmpass) {
         array_push($errors, "Пароли не совпадают");
     } elseif (strlen($this->password) < 6) {
         array_push($errors, "Пароль слишком короткий. Пароль должен быть длиннее 6 символов");
     } elseif ($this->age > 99) {
         array_push($errors, "Возраст введен не корректно.");
     } elseif (!is_numeric($this->age)) {
         array_push($errors, "Возраст должен быть указан в цифрах");
     } elseif ($this->filesize > 1048576 * 5) {
         array_push($errors, "Размер файла должен быть меньше 5 мегабайт");
     } elseif (isset($extension)) {
         if ($extension != 'jpg' && $extension != 'png' && $extension != 'gif') {
             array_push($errors, "Допускается загрузка файлов в формате gif/jpg/png");
         }
     }
     return $errors;
 }
开发者ID:toppestkek,项目名称:Test,代码行数:49,代码来源:Validate.php


示例15: boot

 /**
  * Bootstraps the application.
  *
  * This method is called after all services are registers
  * and should be used for "dynamic" configuration (whenever
  * a service must be requested).
  */
 public function boot(\Silex\Application $app)
 {
     if (isset($app['translator'])) {
         $loaders = array('csv' => new TranslationLoader\CsvFileLoader(), 'ini' => new TranslationLoader\IniFileLoader(), 'mo' => new TranslationLoader\MoFileLoader(), 'php' => new TranslationLoader\PhpFileLoader(), 'xlf' => new TranslationLoader\XliffFileLoader(), 'yml' => new TranslationLoader\YamlFileLoader());
         $registeredLoaders = array();
         // Directory to look for translation file(s)
         $translationDir = dirname(dirname(__DIR__)) . '/resources/translations/' . $app['locale'];
         if (is_dir($translationDir)) {
             $iterator = new \DirectoryIterator($translationDir);
             /**
              * @var \SplFileInfo $fileInfo
              */
             foreach ($iterator as $fileInfo) {
                 if ($fileInfo->isFile()) {
                     $extension = getExtension($fileInfo->getFilename());
                     // $extension = $fileInfo->getExtension(); -- not available before 5.3.7.
                     if (array_key_exists($extension, $loaders)) {
                         if (!array_key_exists($extension, $registeredLoaders)) {
                             // TranslationFileLoader not yet registered
                             $app['translator']->addLoader($extension, $loaders[$extension]);
                         }
                         // There's a file, there's a loader, let's try
                         $fnameParts = explode(".", $fileInfo->getFilename());
                         $domain = $fnameParts[0];
                         $app['translator']->addResource($extension, $fileInfo->getRealPath(), $app['locale'], $domain);
                     }
                 }
             }
         }
         // load fallback for infos domain
         $locale_fb = $app['locale_fallback'];
         $translationDir = dirname(dirname(__DIR__)) . '/resources/translations/' . $locale_fb;
         if (is_dir($translationDir)) {
             $extension = 'yml';
             $domain = 'infos';
             $infosfilename = "{$translationDir}/{$domain}.{$locale_fb}.{$extension}";
             if (is_readable($infosfilename)) {
                 if (array_key_exists($extension, $loaders)) {
                     if (!array_key_exists($extension, $registeredLoaders)) {
                         // TranslationFileLoader not yet registered
                         $app['translator']->addLoader($extension, $loaders[$extension]);
                     }
                     $app['translator']->addResource($extension, $infosfilename, $locale_fb, $domain);
                 }
             }
         }
     }
 }
开发者ID:LeonB,项目名称:site,代码行数:55,代码来源:TranslationServiceProvider.php


示例16: url

 /**
  * @return boolean Returns true when successful.
  */
 public function url($urls, $albumID = 0)
 {
     // Call plugins
     Plugins::get()->activate(__METHOD__, 0, func_get_args());
     $error = false;
     // Parse URLs
     $urls = str_replace(' ', '%20', $urls);
     $urls = explode(',', $urls);
     foreach ($urls as &$url) {
         // Validate photo type and extension even when $this->photo (=> $photo->add) will do the same.
         // This prevents us from downloading invalid photos.
         // Verify extension
         $extension = getExtension($url, true);
         if (!in_array(strtolower($extension), Photo::$validExtensions, true)) {
             $error = true;
             Log::error(Database::get(), __METHOD__, __LINE__, 'Photo format not supported (' . $url . ')');
             continue;
         }
         // Verify image
         $type = @exif_imagetype($url);
         if (!in_array($type, Photo::$validTypes, true)) {
             $error = true;
             Log::error(Database::get(), __METHOD__, __LINE__, 'Photo type not supported (' . $url . ')');
             continue;
         }
         $filename = pathinfo($url, PATHINFO_FILENAME) . $extension;
         $tmp_name = LYCHEE_DATA . $filename;
         if (@copy($url, $tmp_name) === false) {
             $error = true;
             Log::error(Database::get(), __METHOD__, __LINE__, 'Could not copy file (' . $url . ') to temp-folder (' . $tmp_name . ')');
             continue;
         }
         // Import photo
         if (!$this->photo($tmp_name, $albumID)) {
             $error = true;
             Log::error(Database::get(), __METHOD__, __LINE__, 'Could not import file (' . $tmp_name . ')');
             continue;
         }
     }
     // Call plugins
     Plugins::get()->activate(__METHOD__, 1, func_get_args());
     if ($error === false) {
         return true;
     }
     return false;
 }
开发者ID:windhamdavid,项目名称:Lychee,代码行数:49,代码来源:Import.php


示例17: checkUpload

function checkUpload($myFILE, $file_extensions, $mime_types, $maxsize, $ordner)
{
    $errors = array();
    switch ($myFILE['error']) {
        case 1:
            $errors[] = "Wähle eine Datei aus, die <b>kleiner als " . ini_get('upload_max_filesize') . "</b> ist.";
            break;
        case 2:
            $errors[] = "Wähle eine Datei aus, die <b>kleiner als " . $maxsize / (1024 * 1024) . " MB</b> ist.";
            break;
        case 3:
            $errors[] = "Die Datei wurde nur teilweise hochgeladen.";
            break;
        case 4:
            $errors[] = "Es wurde keine Datei ausgewählt.";
            return $errors;
            break;
        default:
            break;
    }
    //MIME-Type prüfen
    if (count($mime_types) != 0 and !in_array(strtolower($myFILE['type']), $mime_types)) {
        $fehler = "Falscher MIME-Type (" . $myFILE['type'] . ").<br />" . "Erlaubte Typen sind:<br />\n";
        foreach ($mime_types as $type) {
            $fehler .= " - " . $type . "\n<br />";
        }
        $errors[] = $fehler;
    }
    //Dateiendung prüfen
    if ($myFILE['name'] == '' or count($file_extensions) != 0 and !in_array(strtolower(getExtension($myFILE['name'])), $file_extensions)) {
        $fehler = "Falsche Dateiendung (" . getExtension($myFILE['name']) . ").<br />" . "Erlaubte Endungen sind:<br />\n";
        foreach ($file_extensions as $extension) {
            $fehler .= " - " . $extension . "\n<br />";
        }
        $errors[] = $fehler;
    }
    //Dateigröße prüfen
    if ($myFILE['size'] > $maxsize) {
        $errors[] = "Datei zu groß (" . sprintf('%.2f', $myFILE['size'] / (1024 * 1024)) . " MB).<br />" . "Erlaubte Größe: " . $maxsize / (1024 * 1024) . " MB\n";
    }
    //Dateiexistenz prüfen
    if (file_exists($ordner . $myFILE['name'])) {
        $errors[] = $myFILE['name'] . " existiert bereits im Zielordner.";
    }
    return $errors;
}
开发者ID:Therealleft,项目名称:CMS-Project-2011,代码行数:46,代码来源:uplfunc.php


示例18: createThumb

function createThumb($source, $destination, $saveName, $targetWidth, $targetHeight)
{
    // Get image size
    $originalSize = getimagesize($source);
    // Set thumb image size
    $targetSize = setWidthHeight($originalSize[0], $originalSize[1], $targetWidth, $targetHeight);
    // Get image extension
    $ext = getExtension($source);
    // Determine source image type
    if ($ext == 'gif') {
        $src = imagecreatefromgif($source);
    } elseif ($ext == 'png') {
        $src = imagecreatefrompng($source);
    } elseif ($ext == 'jpg' || $ext == 'jpeg') {
        $src = imagecreatefromjpeg($source);
    } else {
        return 'Unknow image type !';
    }
    // Copy image
    $dst = imagecreatetruecolor($targetSize[0], $targetSize[1]);
    imagecopyresampled($dst, $src, 0, 0, 0, 0, $targetSize[0], $targetSize[1], $originalSize[0], $originalSize[1]);
    if (!file_exists($destination)) {
        if (!createRDir($destination)) {
            return 'Unabled to create destination folder !';
        }
    }
    // destination + fileName
    $thumbName = $destination . '/' . $saveName . '.' . $ext;
    if ($ext == 'gif') {
        imagegif($dst, $thumbName);
    } else {
        if ($ext == 'png') {
            imagepng($dst, $thumbName);
        } else {
            if ($ext == 'jpg' || $ext == 'jpeg') {
                imagejpeg($dst, $thumbName, 100);
            } else {
                return 'Fail to create thumb !';
            }
        }
    }
    imagedestroy($dst);
    imagedestroy($src);
    return $thumbName;
}
开发者ID:GobYang,项目名称:thaidh,代码行数:45,代码来源:F_Img.php


示例19: deleteExtensionFiles

function deleteExtensionFiles($dir, $extension)
{
    $dirs = scandir($dir);
    // Do not scan current and parent dir:
    $exceptDirs = array('.', '..');
    foreach ($dirs as $key => $value) {
        if (!in_array($value, $exceptDirs)) {
            if (is_dir($dir . DS . $value)) {
                $dd = deleteExtensionFiles($dir . DS . $value, $extension);
            } else {
                $ext = getExtension($value);
                if ($ext == $extension) {
                    @unlink($value);
                }
            }
        }
    }
}
开发者ID:xn1224,项目名称:YOF,代码行数:18,代码来源:F_File.php


示例20: make_thumb

function make_thumb($img_name, $filename, $new_w, $new_h)
{
    //get image extension.
    $ext = getExtension($img_name);
    //creates the new image using the appropriate function from gd library
    if (!strcmp("jpg", $ext) || !strcmp("jpeg", $ext)) {
        $src_img = imagecreatefromjpeg($img_name);
    }
    if (!strcmp("png", $ext)) {
        $src_img = imagecreatefrompng($img_name);
    }
    //gets the dimmensions of the image
    $old_x = imageSX($src_img);
    $old_y = imageSY($src_img);
    // next we will calculate the new dimmensions for the thumbnail image
    // the next steps will be taken:
    // 1. calculate the ratio by dividing the old dimmensions with the new ones
    // 2. if the ratio for the width is higher, the width will remain the one define in WIDTH variable
    // and the height will be calculated so the image ratio will not change
    // 3. otherwise we will use the height ratio for the image
    // as a result, only one of the dimmensions will be from the fixed ones
    $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;
    }
    // we create a new image with the new dimmensions
    $dst_img = ImageCreateTrueColor($thumb_w, $thumb_h);
    // resize the big image to the new created one
    imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $thumb_w, $thumb_h, $old_x, $old_y);
    // output the created image to the file. Now we will have the thumbnail into the file named by $filename
    if (!strcmp("png", $ext)) {
        imagepng($dst_img, $filename);
    } else {
        imagejpeg($dst_img, $filename);
    }
    //destroys source and destination images.
    imagedestroy($dst_img);
    imagedestroy($src_img);
}
开发者ID:gepeng05,项目名称:AUB-onlineshop,代码行数:44,代码来源:fungsi_thumb.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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