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

PHP finfo_buffer函数代码示例

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

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



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

示例1: createBinary

 /**
  * Init image from uploaded file
  * @param $imageData
  * @return Binary
  */
 private function createBinary($imageData)
 {
     $f = finfo_open();
     $mimeType = finfo_buffer($f, $imageData, FILEINFO_MIME_TYPE);
     $binary = new Binary($imageData, $mimeType, $this->extensionGuesser->guess($mimeType));
     return $binary;
 }
开发者ID:symfonyway,项目名称:upload-handler,代码行数:12,代码来源:ImageHandler.php


示例2: isBinary

 public static function isBinary($path)
 {
     if (false === is_readable($path)) {
         Exception::raise($path . ' is not readable', 2);
     }
     $size = filesize($path);
     if ($size < 2) {
         return false;
     }
     $data = file_get_contents($path, false, null, -1, 5012);
     if (false && function_exists('finfo_open')) {
         $finfo = finfo_open(FILEINFO_MIME_ENCODING);
         $encode = finfo_buffer($finfo, $data, FILEINFO_MIME_ENCODING);
         finfo_close($finfo);
         $data = null;
         return $encode === 'binary';
     }
     $buffer = '';
     for ($i = 0; $i < $size; ++$i) {
         if (isset($data[$i])) {
             $buffer .= sprintf('%08b', ord($data[$i]));
         }
     }
     $data = null;
     return preg_match('#^[0-1]+$#', $buffer) === 1;
 }
开发者ID:inphinit,项目名称:framework,代码行数:26,代码来源:File.php


示例3: getContentMimeType

 /**
  * Returns the MIME-type of content in string
  * @param string $content
  * @return string Content mime-type
  */
 public static function getContentMimeType($content)
 {
     $finfo = finfo_open(FILEINFO_MIME_TYPE);
     $mimeType = finfo_buffer($finfo, $content);
     finfo_close($finfo);
     return $mimeType;
 }
开发者ID:hiqdev,项目名称:hipanel-core,代码行数:12,代码来源:FileHelper.php


示例4: make

 public function make()
 {
     $mime = finfo_buffer(finfo_open(FILEINFO_MIME_TYPE), $this->ivatar->encode);
     $length = strlen($this->ivatar->encode);
     $response = \Response::make($this->ivatar->encode);
     $response->header('Content-Type', $mime);
     $response->header('Content-Length', $length);
     return $response;
 }
开发者ID:cloudratha,项目名称:ivatar,代码行数:9,代码来源:Response.php


示例5: boot

 /**
  * Bootstrap the application events.
  *
  * @return void
  */
 public function boot()
 {
     $this->package('intervention/image');
     // try to create imagecache route only if imagecache is present
     if (class_exists('Intervention\\Image\\ImageCache')) {
         $app = $this->app;
         // load imagecache config
         $app['config']->package('intervention/imagecache', __DIR__ . '/../../../../imagecache/src/config', 'imagecache');
         $config = $app['config'];
         // create dynamic manipulation route
         if (is_string($config->get('imagecache::route'))) {
             // add original to route templates
             $config->set('imagecache::templates.original', null);
             // setup image manipulator route
             $app['router']->get($config->get('imagecache::route') . '/{template}/{filename}', array('as' => 'imagecache', function ($template, $filename) use($app, $config) {
                 // disable session cookies for image route
                 $app['config']->set('session.driver', 'array');
                 // find file
                 foreach ($config->get('imagecache::paths') as $path) {
                     // don't allow '..' in filenames
                     $image_path = $path . '/' . str_replace('..', '', $filename);
                     if (file_exists($image_path) && is_file($image_path)) {
                         break;
                     } else {
                         $image_path = false;
                     }
                 }
                 // abort if file not found
                 if ($image_path === false) {
                     $app->abort(404);
                 }
                 // define template callback
                 $callback = $config->get("imagecache::templates.{$template}");
                 if (is_callable($callback) || class_exists($callback)) {
                     // image manipulation based on callback
                     $content = $app['image']->cache(function ($image) use($image_path, $callback) {
                         switch (true) {
                             case is_callable($callback):
                                 return $callback($image->make($image_path));
                                 break;
                             case class_exists($callback):
                                 return $image->make($image_path)->filter(new $callback());
                                 break;
                         }
                     }, $config->get('imagecache::lifetime'));
                 } else {
                     // get original image file contents
                     $content = file_get_contents($image_path);
                 }
                 // define mime type
                 $mime = finfo_buffer(finfo_open(FILEINFO_MIME_TYPE), $content);
                 // return http response
                 return new IlluminateResponse($content, 200, array('Content-Type' => $mime, 'Cache-Control' => 'max-age=' . $config->get('imagecache::lifetime') * 60 . ', public', 'Etag' => md5($content)));
             }))->where(array('template' => join('|', array_keys($config->get('imagecache::templates'))), 'filename' => '[ \\w\\.\\/\\-]+'));
         }
     }
 }
开发者ID:hilmysyarif,项目名称:sic,代码行数:62,代码来源:ImageServiceProviderLaravel4.php


示例6: 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


示例7: initFromBinary

 /**
  * Initiates new image from binary data
  *
  * @param  string $data
  * @return \Intervention\Image\Image
  */
 public function initFromBinary($binary)
 {
     $resource = @imagecreatefromstring($binary);
     if ($resource === false) {
         throw new \Intervention\Image\Exception\NotReadableException("Unable to init from given binary data.");
     }
     $image = $this->initFromGdResource($resource);
     $image->mime = finfo_buffer(finfo_open(FILEINFO_MIME_TYPE), $binary);
     return $image;
 }
开发者ID:alvarobfdev,项目名称:applog,代码行数:16,代码来源:Decoder.php


示例8: getMIMEEncoding

 /**
  * Get the mime encoding (e.g. "binary" or "us-ascii" or "utf-8") of the file.
  *
  * @return string
  */
 public function getMIMEEncoding()
 {
     $adapter = $this->file->internalPathname()->localAdapter();
     if ($adapter instanceof MimeAwareAdapterInterface) {
         return $adapter->getMimeEncoding($this->file->internalPathname());
     }
     return Util::executeFunction(function () {
         return finfo_buffer(Util::getFileInfo(), $this->file->getContents(), FILEINFO_MIME_ENCODING);
     }, 'Filicious\\Exception\\PluginException', 0, 'Could not determine mime encoding');
 }
开发者ID:filicious,项目名称:core,代码行数:15,代码来源:MimeFilePlugin.php


示例9: get

 public function get($filename)
 {
     $path = config('images.path') . $filename;
     if (!Storage::exists($path)) {
         throw new ImageNotFoundHttpException();
     }
     $data = Storage::get($path);
     $mime = finfo_buffer(finfo_open(FILEINFO_MIME_TYPE), $data);
     return Response::make($data)->header('Content-Type', $mime)->header('Content-Length', strlen($data));
 }
开发者ID:B1naryStudio,项目名称:asciit,代码行数:10,代码来源:ImageService.php


示例10: execute

 /**
  * Builds PSR7 compatible response. May replace "response" command in
  * some future.
  *
  * Method will generate binary stream and put it inside PSR-7
  * ResponseInterface. Following code can be optimized using native php
  * streams and more "clean" streaming, however drivers has to be updated
  * first.
  *
  * @param  \Intervention\Image\Image $image
  * @return boolean
  */
 public function execute($image)
 {
     $format = $this->argument(0)->value();
     $quality = $this->argument(1)->between(0, 100)->value();
     //Encoded property will be populated at this moment
     $stream = $image->stream($format, $quality);
     $mimetype = finfo_buffer(finfo_open(FILEINFO_MIME_TYPE), $image->getEncoded());
     $this->setOutput(new Response(200, array('Content-Type' => $mimetype, 'Content-Length' => strlen($image->getEncoded())), $stream));
     return true;
 }
开发者ID:hilmysyarif,项目名称:sic,代码行数:22,代码来源:PsrResponseCommand.php


示例11: getMimetype

 /**
  * Get the file's mimetype.
  * 
  * @return string
  */
 public function getMimetype()
 {
     $finfo = finfo_open(FILEINFO_MIME_TYPE);
     $mime_type = finfo_buffer($finfo, $this->getContent());
     finfo_close($finfo);
     if (strpos($mime_type, ';') !== false) {
         list($mime_type, $info) = explode(';', $mime_type);
     }
     return trim($mime_type);
 }
开发者ID:bfrager,项目名称:evernote-ocr,代码行数:15,代码来源:IlluminateFileAdapter.php


示例12: show

 public function show($id)
 {
     $user = DB::table('tbl_admins')->where('tbl_admins.id', '=', $id)->join('cat_datos_maestros as genero', 'tbl_admins.lng_idgenero', '=', 'genero.id')->join('cat_roles', 'tbl_admins.lng_idrol', '=', 'cat_roles.id')->select('tbl_admins.id', 'tbl_admins.name', 'tbl_admins.str_cedula', 'tbl_admins.str_nombre', 'tbl_admins.str_apellido', 'genero.str_descripcion as genero', 'tbl_admins.str_telefono', 'tbl_admins.email', 'tbl_admins.created_at', 'cat_roles.str_rol', 'tbl_admins.bol_eliminado', 'tbl_admins.blb_img')->get();
     // Detectando el Tipo de Formato del la Imagen
     $a = base64_decode($user[0]->blb_img);
     $b = finfo_open();
     //Agregando un nuevo atributo al array
     $user[0]->format = finfo_buffer($b, $a, FILEINFO_MIME_TYPE);
     //return $persona;
     return view('admin.show', ['user' => $user])->with('page_title', 'Consultar');
 }
开发者ID:nbarazarte,项目名称:neeladmintroovami,代码行数:11,代码来源:AdminController.php


示例13: uploadBase64

 /**
  * @param string $base64Data
  * @param string $prefix
  * @param string $extension
  * @param int    $width
  * @param int    $height
  *
  * @return string
  */
 public function uploadBase64($base64Data, $prefix = 'avatar/', $extension = 'jpg', $width = null, $height = null)
 {
     $data = base64_decode($base64Data);
     $resource = finfo_open();
     $mime_type = finfo_buffer($resource, $data, FILEINFO_MIME_TYPE);
     $map = array('image/gif' => 'gif', 'image/jpeg' => 'jpg', 'image/png' => 'png');
     if ($mime_type && isset($map[$mime_type])) {
         $extension = $map[$mime_type];
     }
     return $this->uploadData($data, $prefix, $extension, $width, $height);
 }
开发者ID:oriodesign,项目名称:tastd-backend-demo,代码行数:20,代码来源:S3Client.php


示例14: image_base64

 public static function image_base64($url)
 {
     $image = file_get_contents($url);
     $f = finfo_open();
     $mime_type = finfo_buffer($f, $image, FILEINFO_MIME_TYPE);
     if (in_array($mime_type, array('image/png', 'image/jpeg', 'image/gif'))) {
         return "data:{$mime_type};base64," . base64_encode($image);
     } else {
         return null;
     }
 }
开发者ID:wave-framework,项目名称:scaffolding-app,代码行数:11,代码来源:Utils.php


示例15: detectFromResource

 /**
  * Detect mime type from a resource.
  *
  * @param  resource $resource
  * @return string
  */
 public function detectFromResource($resource)
 {
     $handle = $this->getHandle();
     $meta = stream_get_meta_data($resource);
     if (file_exists($meta['uri'])) {
         $type = finfo_file($handle, $meta['uri']);
     } else {
         $type = finfo_buffer($handle, fread($resource, 1000000));
     }
     return $this->fixType($type);
 }
开发者ID:dotsunited,项目名称:cabinet,代码行数:17,代码来源:FileinfoDetector.php


示例16: analyze

 public function analyze($handle)
 {
     $meta = stream_get_meta_data($handle);
     if (file_exists($meta['uri'])) {
         $result = finfo_file($this->_resource, $meta['uri']);
     } else {
         $result = finfo_buffer($this->_resource, fread($handle, 1000000));
     }
     if ($result != 'application/x-empty') {
         return $result;
     }
 }
开发者ID:razzman,项目名称:media,代码行数:12,代码来源:Fileinfo.php


示例17: getMIMETypeFromContents

 public static function getMIMETypeFromContents($fileContents)
 {
     // get mime type
     $finfo = finfo_open(FILEINFO_MIME, static::$magicPath);
     if (!$finfo || !($mimeInfo = finfo_buffer($finfo, $fileContents))) {
         throw new Exception('Unable to load file info');
     }
     finfo_close($finfo);
     // split mime type
     $p = strpos($mimeInfo, ';');
     return $p ? substr($mimeInfo, 0, $p) : $mimeInfo;
 }
开发者ID:JarvusInnovations,项目名称:Emergence-preview,代码行数:12,代码来源:File.class.php


示例18: process

 public function process($url)
 {
     $fname = basename($url);
     $this->mediaData->originalName = strlen($fname) > 255 ? md5($fname) : $fname;
     $this->fileData = file_get_contents($url);
     // get mime using finfo.
     $finfo = finfo_open(FILEINFO_MIME_TYPE);
     $mime = finfo_buffer($finfo, $this->fileData);
     $this->mediaData->mime = $mime === FALSE ? "application/octet-stream" : $mime;
     $this->mediaData->size = strlen($this->fileData);
     return;
 }
开发者ID:rjha,项目名称:webgloo,代码行数:12,代码来源:UrlPipe.php


示例19: prepareHtmlMail

 function prepareHtmlMail($html, $eol, $boundary_rel, $boundary_alt)
 {
     preg_match_all('~<img.*?src=.([\\/.a-z0-9:;,+=_-]+).*?>~si', $html, $matches);
     $i = 0;
     $paths = array();
     foreach ($matches[1] as $img) {
         $img_old = $img;
         if (strpos($img, "http://") === false) {
             $paths[$i]['img'] = $img;
             $content_id = md5($img);
             $html = str_replace($img_old, 'cid:' . $content_id, $html);
             $paths[$i++]['cid'] = $content_id;
         }
     }
     $multipart = '';
     $multipart .= "{$boundary_alt}{$eol}";
     $multipart .= "Content-Type: text/plain; charset=UTF-8{$eol}{$eol}{$eol}";
     $multipart .= "{$boundary_alt}{$eol}";
     $multipart .= "Content-Type: text/html; charset=UTF-8{$eol}{$eol}";
     $multipart .= "{$html}{$eol}{$eol}";
     $multipart .= "{$boundary_alt}--{$eol}";
     foreach ($paths as $key => $path) {
         $img_data = explode(",", $path["img"]);
         $imgdata = base64_decode($img_data[1]);
         $f = finfo_open();
         $mime_type = finfo_buffer($f, $imgdata, FILEINFO_MIME_TYPE);
         $filename = "image_{$key}";
         switch ($mime_type) {
             case "image/jpeg":
                 $filename .= ".jpg";
                 break;
             case "image/png":
                 $filename .= ".jpg";
                 break;
             case "image/gif":
                 $filename .= ".jpg";
                 break;
             default:
                 $filename .= ".jpg";
                 break;
         }
         $message_part .= "Content-Type: {$mime_type}; name=\"{$filename}\"{$eol}";
         $message_part .= "Content-Disposition: inline; filename=\"{$filename}\"{$eol}";
         $message_part .= "Content-Transfer-Encoding: base64{$eol}";
         $message_part .= "Content-ID: <{$path['cid']}>{$eol}";
         $message_part .= "X-Attachment-Id: {$path['cid']}{$eol}{$eol}";
         $message_part .= $img_data[1];
         $multipart .= "{$boundary_rel}{$eol}" . $message_part . "{$eol}";
     }
     $multipart .= "{$boundary_rel}--";
     return $multipart;
 }
开发者ID:richardkeep,项目名称:tina4stack,代码行数:52,代码来源:Emma.php


示例20: initFromBinary

 /**
  * Initiates new image from binary data
  *
  * @param  string $data
  * @return \Intervention\Image\Image
  */
 public function initFromBinary($binary)
 {
     $core = new \Imagick();
     try {
         $core->readImageBlob($binary);
     } catch (\ImagickException $e) {
         throw new \Intervention\Image\Exception\NotReadableException("Unable to read image from binary data.", 0, $e);
     }
     // build image
     $image = $this->initFromImagick($core);
     $image->mime = finfo_buffer(finfo_open(FILEINFO_MIME_TYPE), $binary);
     return $image;
 }
开发者ID:drickferreira,项目名称:rastreador,代码行数:19,代码来源:Decoder.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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