readFile() публичный Метод

下载文件
public readFile ( string $path, mixed $file_handle = NULL ) : mixed
$path string 文件路径
$file_handle mixed
Результат mixed
Пример #1
0
 public function getFileContent($filename)
 {
     $filename = trim($filename);
     $config = $this->getConfig();
     tsload(ADDON_PATH . '/library/upyun.class.php');
     $cloud = new UpYun($config['cloud_attach_bucket'], $config['cloud_attach_admin'], $config['cloud_attach_password']);
     $cloud->setTimeout(60);
     $content = $cloud->readFile('/' . $filename);
     if (!$content) {
         $this->error = '读取云附件失败!';
         return false;
     } else {
         return $content;
     }
 }
Пример #2
0
 function ftp_get($local_file, $remote_file, $mode, $resumepos = 0)
 {
     $upyun = new UpYun($this->upyun_config['bucket_name'], $this->upyun_config['operator_name'], $this->upyun_config['operator_pwd']);
     $remote_file = discuz_ftp::clear($remote_file);
     $local_file = discuz_ftp::clear($local_file);
     try {
         if ($fh = fopen($local_file, 'wb')) {
             $rsp = $upyun->readFile($this->upyun_dir . ltrim($remote_file, '/'), $fh);
             fclose($fh);
             return $rsp;
         } else {
             return 0;
         }
     } catch (Exception $e) {
         return 0;
     }
 }
Пример #3
0
<?php

@header('Content-Type: text/html; charset=utf-8');
require_once 'upyun.class.php';
require_once '../../../cscms/lib/Cs_Upyun.php';
$uri = $_SERVER["REQUEST_URI"];
$code = explode("down.php", $uri);
$path = explode("?size", $code[1]);
$upyun = new UpYun(CS_Upy_Bucket, CS_Upy_Name, CS_Upy_Pwd);
header('Content-type: application/force-download');
echo $upyun->readFile($path[0]);