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


PHP OC_Response::setContentDispositionHeader方法代码示例

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


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

示例1: sendHeaders

 /**
  * @param string $filename
  * @param string $name
  */
 private static function sendHeaders($filename, $name)
 {
     OC_Response::setContentDispositionHeader($name, 'attachment');
     header('Content-Transfer-Encoding: binary');
     OC_Response::disableCaching();
     $filesize = \OC\Files\Filesystem::filesize($filename);
     header('Content-Type: ' . \OC_Helper::getSecureMimeType(\OC\Files\Filesystem::getMimeType($filename)));
     if ($filesize > -1) {
         OC_Response::setContentLengthHeader($filesize);
     }
 }
开发者ID:hyb148,项目名称:core,代码行数:15,代码来源:files.php

示例2: sendHeaders

 /**
  * @param string $filename
  * @param string $name
  * @param boolean $isAttachment ; enforce download of file
  */
 private static function sendHeaders($filename, $name, $isAttachment = true)
 {
     if ($isAttachment) {
         OC_Response::setContentDispositionHeader($name, 'attachment');
     }
     header('Content-Transfer-Encoding: binary');
     OC_Response::disableCaching();
     $fileSize = \OC\Files\Filesystem::filesize($filename);
     $type = \OC::$server->getMimeTypeDetector()->getSecureMimeType(\OC\Files\Filesystem::getMimeType($filename));
     header('Content-Type: ' . $type);
     if ($fileSize > -1) {
         OC_Response::setContentLengthHeader($fileSize);
     }
 }
开发者ID:0x17de,项目名称:core,代码行数:19,代码来源:files.php

示例3: sendHeaders

 /**
  * @param string $filename
  * @param string $name
  * @param bool $zip
  */
 private static function sendHeaders($filename, $name, $zip = false)
 {
     OC_Response::setContentDispositionHeader($name, 'attachment');
     header('Content-Transfer-Encoding: binary');
     OC_Response::disableCaching();
     if ($zip) {
         header('Content-Type: application/zip');
     } else {
         $filesize = \OC\Files\Filesystem::filesize($filename);
         header('Content-Type: ' . \OC\Files\Filesystem::getMimeType($filename));
         if ($filesize > -1) {
             header("Content-Length: " . $filesize);
         }
     }
 }
开发者ID:olucao,项目名称:owncloud-core,代码行数:20,代码来源:files.php

示例4: sendHeaders

 /**
  * @param string $filename
  * @param string $name
  * @param array $rangeArray ('from'=>int,'to'=>int), ...
  */
 private static function sendHeaders($filename, $name, array $rangeArray)
 {
     OC_Response::setContentDispositionHeader($name, 'attachment');
     header('Content-Transfer-Encoding: binary', true);
     OC_Response::disableCaching();
     $fileSize = \OC\Files\Filesystem::filesize($filename);
     $type = \OC::$server->getMimeTypeDetector()->getSecureMimeType(\OC\Files\Filesystem::getMimeType($filename));
     if ($fileSize > -1) {
         if (!empty($rangeArray)) {
             header('HTTP/1.1 206 Partial Content', true);
             header('Accept-Ranges: bytes', true);
             if (count($rangeArray) > 1) {
                 $type = 'multipart/byteranges; boundary=' . self::getBoundary();
                 // no Content-Length header here
             } else {
                 header(sprintf('Content-Range: bytes %d-%d/%d', $rangeArray[0]['from'], $rangeArray[0]['to'], $fileSize), true);
                 OC_Response::setContentLengthHeader($rangeArray[0]['to'] - $rangeArray[0]['from'] + 1);
             }
         } else {
             OC_Response::setContentLengthHeader($fileSize);
         }
     }
     header('Content-Type: ' . $type, true);
 }
开发者ID:GitHubUser4234,项目名称:core,代码行数:29,代码来源:files.php

示例5: setContentDispositionHeader

 /**
  * Sets the content disposition header (with possible workarounds)
  * @param string $filename file name
  * @param string $type disposition type, either 'attachment' or 'inline'
  */
 public static function setContentDispositionHeader($filename, $type = 'attachment')
 {
     \OC_Response::setContentDispositionHeader($filename, $type);
 }
开发者ID:adolfo2103,项目名称:hcloudfilem,代码行数:9,代码来源:response.php

示例6: get

 /**
  * return the content of a file or return a zip file containing multiple files
  *
  * @param string $dir
  * @param string $file ; separated list of files to download
  * @param boolean $only_header ; boolean to only send header of the request
  */
 public static function get($dir, $files, $only_header = false)
 {
     $xsendfile = false;
     if (isset($_SERVER['MOD_X_SENDFILE_ENABLED']) || isset($_SERVER['MOD_X_SENDFILE2_ENABLED']) || isset($_SERVER['MOD_X_ACCEL_REDIRECT_ENABLED'])) {
         $xsendfile = true;
     }
     if (is_array($files) && count($files) == 1) {
         $files = $files[0];
     }
     if (is_array($files)) {
         self::validateZipDownload($dir, $files);
         $executionTime = intval(ini_get('max_execution_time'));
         set_time_limit(0);
         $zip = new ZipArchive();
         $filename = OC_Helper::tmpFile('.zip');
         if ($zip->open($filename, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE) !== true) {
             $l = OC_L10N::get('lib');
             throw new Exception($l->t('cannot open "%s"', array($filename)));
         }
         foreach ($files as $file) {
             $file = $dir . '/' . $file;
             if (\OC\Files\Filesystem::is_file($file)) {
                 $tmpFile = \OC\Files\Filesystem::toTmpFile($file);
                 self::$tmpFiles[] = $tmpFile;
                 $zip->addFile($tmpFile, basename($file));
             } elseif (\OC\Files\Filesystem::is_dir($file)) {
                 self::zipAddDir($file, $zip);
             }
         }
         $zip->close();
         if ($xsendfile) {
             $filename = OC_Helper::moveToNoClean($filename);
         }
         $basename = basename($dir);
         if ($basename) {
             $name = $basename . '.zip';
         } else {
             $name = 'download.zip';
         }
         set_time_limit($executionTime);
     } elseif (\OC\Files\Filesystem::is_dir($dir . '/' . $files)) {
         self::validateZipDownload($dir, $files);
         $executionTime = intval(ini_get('max_execution_time'));
         set_time_limit(0);
         $zip = new ZipArchive();
         $filename = OC_Helper::tmpFile('.zip');
         if ($zip->open($filename, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE) !== true) {
             $l = OC_L10N::get('lib');
             throw new Exception($l->t('cannot open "%s"', array($filename)));
         }
         $file = $dir . '/' . $files;
         self::zipAddDir($file, $zip);
         $zip->close();
         if ($xsendfile) {
             $filename = OC_Helper::moveToNoClean($filename);
         }
         $name = $files . '.zip';
         set_time_limit($executionTime);
     } else {
         $zip = false;
         $filename = $dir . '/' . $files;
         $name = $files;
         if ($xsendfile && OC_App::isEnabled('files_encryption')) {
             $xsendfile = false;
         }
     }
     OC_Util::obEnd();
     if ($zip or \OC\Files\Filesystem::isReadable($filename)) {
         OC_Response::setContentDispositionHeader($name, 'attachment');
         header('Content-Transfer-Encoding: binary');
         OC_Response::disableCaching();
         if ($zip) {
             ini_set('zlib.output_compression', 'off');
             header('Content-Type: application/zip');
             header('Content-Length: ' . filesize($filename));
             self::addSendfileHeader($filename);
         } else {
             $filesize = \OC\Files\Filesystem::filesize($filename);
             header('Content-Type: ' . \OC\Files\Filesystem::getMimeType($filename));
             if ($filesize > -1) {
                 header("Content-Length: " . $filesize);
             }
             if ($xsendfile) {
                 list($storage) = \OC\Files\Filesystem::resolvePath(\OC\Files\Filesystem::getView()->getAbsolutePath($filename));
                 /**
                  * @var \OC\Files\Storage\Storage $storage
                  */
                 if ($storage->instanceOfStorage('\\OC\\Files\\Storage\\Local')) {
                     self::addSendfileHeader(\OC\Files\Filesystem::getLocalFile($filename));
                 }
             }
         }
     } elseif ($zip or !\OC\Files\Filesystem::file_exists($filename)) {
//.........这里部分代码省略.........
开发者ID:hjimmy,项目名称:owncloud,代码行数:101,代码来源:files.php


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