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


PHP File::seek方法代码示例

本文整理汇总了PHP中Bitrix\Main\IO\File::seek方法的典型用法代码示例。如果您正苦于以下问题:PHP File::seek方法的具体用法?PHP File::seek怎么用?PHP File::seek使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Bitrix\Main\IO\File的用法示例。


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

示例1: ViewByUser


//.........这里部分代码省略.........
             //Handle ETag
             $ETag = md5($filename . $filesize . $filetime);
             if (array_key_exists("HTTP_IF_NONE_MATCH", $_SERVER) && $_SERVER['HTTP_IF_NONE_MATCH'] === $ETag) {
                 CHTTP::SetStatus("304 Not Modified");
                 header("Cache-Control: private, max-age=" . $cache_time . ", pre-check=" . $cache_time);
                 die;
             }
             header("ETag: " . $ETag);
             //Handle Last Modified
             if ($filetime > 0) {
                 $lastModified = gmdate('D, d M Y H:i:s', $filetime) . ' GMT';
                 if (array_key_exists("HTTP_IF_MODIFIED_SINCE", $_SERVER) && $_SERVER['HTTP_IF_MODIFIED_SINCE'] === $lastModified) {
                     CHTTP::SetStatus("304 Not Modified");
                     header("Cache-Control: private, max-age=" . $cache_time . ", pre-check=" . $cache_time);
                     die;
                 }
             }
         }
         $utfName = CHTTP::urnEncode($attachment_name, "UTF-8");
         $translitName = CUtil::translit($attachment_name, LANGUAGE_ID, array("max_len" => 1024, "safe_chars" => ".", "replace_space" => '-'));
         if ($force_download) {
             //Disable zlib for old versions of php <= 5.3.0
             //it has broken Content-Length handling
             if (ini_get('zlib.output_compression')) {
                 ini_set('zlib.output_compression', 'Off');
             }
             if ($cur_pos > 0) {
                 CHTTP::SetStatus("206 Partial Content");
             } else {
                 CHTTP::SetStatus("200 OK");
             }
             header("Content-Type: " . $content_type);
             header("Content-Disposition: attachment; filename=\"" . $translitName . "\"; filename*=utf-8''" . $utfName);
             header("Content-Transfer-Encoding: binary");
             header("Content-Length: " . ($size - $cur_pos + 1));
             if (is_resource($src)) {
                 header("Accept-Ranges: bytes");
                 header("Content-Range: bytes " . $cur_pos . "-" . $size . "/" . $filesize);
             }
         } else {
             header("Content-Type: " . $content_type);
             header("Content-Disposition: inline; filename=\"" . $translitName . "\"; filename*=utf-8''" . $utfName);
         }
         if ($cache_time > 0) {
             header("Cache-Control: private, max-age=" . $cache_time . ", pre-check=" . $cache_time);
             if ($filetime > 0) {
                 header('Last-Modified: ' . $lastModified);
             }
         } else {
             header("Cache-Control: no-cache, must-revalidate, post-check=0, pre-check=0");
         }
         header("Expires: 0");
         header("Pragma: public");
         // Download from front-end
         if ($fastDownload) {
             if ($fromClouds) {
                 $filename = preg_replace('~^(http[s]?)(\\://)~i', '\\1.', $filename);
                 $cloudUploadPath = COption::GetOptionString('main', 'bx_cloud_upload', '/upload/bx_cloud_upload/');
                 header('X-Accel-Redirect: ' . $cloudUploadPath . $filename);
             } else {
                 $filename = $APPLICATION->ConvertCharset($filename, SITE_CHARSET, "UTF-8");
                 header('X-Accel-Redirect: ' . $filename);
             }
         } else {
             session_write_close();
             if ($specialchars) {
                 echo "<", "pre", ">";
                 if (is_resource($src)) {
                     while (!feof($src)) {
                         echo htmlspecialcharsbx(fread($src, 32768));
                     }
                     $file->close();
                 } else {
                     echo htmlspecialcharsbx($src->get($filename));
                 }
                 echo "<", "/pre", ">";
             } else {
                 if (is_resource($src)) {
                     $file->seek($cur_pos);
                     while (!feof($src) && $cur_pos <= $size) {
                         $bufsize = 131072;
                         //128K
                         if ($cur_pos + $bufsize > $size) {
                             $bufsize = $size - $cur_pos + 1;
                         }
                         $cur_pos += $bufsize;
                         echo fread($src, $bufsize);
                     }
                     $file->close();
                 } else {
                     $fp = fopen("php://output", "wb");
                     $src->setOutputStream($fp);
                     $src->get($filename);
                 }
             }
         }
     }
     CMain::FinalActions();
     die;
 }
开发者ID:nycmic,项目名称:bittest,代码行数:101,代码来源:file.php


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