本文整理匯總了PHP中IO::getStream方法的典型用法代碼示例。如果您正苦於以下問題:PHP IO::getStream方法的具體用法?PHP IO::getStream怎麽用?PHP IO::getStream使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類IO
的用法示例。
在下文中一共展示了IO::getStream方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: multiUpload
public function multiUpload($opath, $path, $filename, $attach = array(), $ondup = "newcopy")
{
global $_G;
/*
* 分塊上傳文件
* param $file:文件路徑(可以是url路徑,需要服務器開啟allow_url_fopen);
*/
$partsize = 1024 * 1024 * 5;
//分塊大小2M
if ($attach) {
$data = $attach;
$data['size'] = $attach['filesize'];
} else {
$data = IO::getMeta($opath);
if ($data['error']) {
return $data;
}
}
$size = $data['size'];
if (is_array($filepath = IO::getStream($opath))) {
return array('error' => $filepath['error']);
}
if ($size < $partsize) {
//獲取文件內容
if (!($handle = fopen($filepath, 'rb'))) {
return array('error' => '打開文件錯誤');
}
while (!feof($handle)) {
$fileContent .= fread($handle, 8192);
//if(strlen($fileContent)==0) return array('error'=>'文件不存在');
}
return self::upload($fileContent, $path, $filename, false, $ondup);
} else {
//分片上傳
self::deleteCache($path . $filename);
if (!($handle = fopen($filepath, 'rb'))) {
return array('error' => '打開文件錯誤');
}
$fileContent = '';
while (!feof($handle)) {
$fileContent .= fread($handle, 8192);
//if(strlen($fileContent)==0) return array('error'=>'文件不存在');
if (strlen($fileContent) >= $partsize) {
$re = self::upload($fileContent, $path, $filename, true, $ondup);
if ($re['error']) {
return $re;
}
$fileContent = '';
}
}
fclose($handle);
if (!empty($fileContent)) {
$re = self::upload($fileContent, $path, $filename, true, $ondup);
if ($re['error']) {
return $re;
}
}
//分片上傳結束,合並分片文件
return self::createSuperFile($path, $filename, $ondup);
}
}
示例2: multiUpload
public function multiUpload($opath, $path, $filename, $attach = array(), $ondup = "newcopy")
{
global $_G;
if (is_array($filepath = IO::getStream($opath))) {
return array('error' => $filepath['error']);
}
//exit($filepath);
return self::upload($filepath, $path, $filename);
}
示例3: libfile
*/
@set_time_limit(0);
include_once libfile('class/ZipStream');
$patharr = $_GET['paths'];
print_r($_GET);
exit('dfdsfsf');
$meta = IO::getMeta(dzzdecode($patharr[0]));
if ($meta['error']) {
exit($meta['error']);
}
$filename = strtolower(CHARSET) == 'utf-8' && (strexists($_SERVER['HTTP_USER_AGENT'], 'MSIE') || strexists($_SERVER['HTTP_USER_AGENT'], 'rv:11')) ? urlencode($meta['name']) : $meta['name'];
$zip = new ZipStream($filename . ".zip");
foreach ($patharr as $dpath) {
$path = dzzdecode($dpath);
$meta = IO::getMeta($path);
switch ($meta['type']) {
case 'app':
case 'video':
case 'dzzdoc':
case 'link':
continue;
break;
case 'folder':
IO::getFolderInfo($path, $meta['name'], $zip);
break;
default:
$zip->addLargeFile(fopen(IO::getStream($path), 'rb'), $meta['name'], $meta['dateline']);
break;
}
}
$zip->finalize();
示例4: preg_replace
$url = preg_replace("/{(\\w+)}/ie", "cansu_replace('\\1')", $url);
//添加path參數;
if (strpos($url, '?') !== false && strpos($url, 'path=') === false) {
$url .= '&path=' . $_GET['s'];
}
@header("Location: {$url}");
exit;
}
} else {
//沒有可用的打開方式,轉入下載;
IO::download($path);
exit;
}
}
//獲取文件流地址
if (!($url = IO::getStream($path))) {
exit('獲取文件失敗');
}
if (is_array($url)) {
exit($url['error']);
}
//如果是阻止運行的後綴名時,直接調用;
if ($ext && in_array($ext, $_G['setting']['unRunExts'])) {
$mime = 'text/plain';
} else {
$mime = dzz_mime::get_type($ext);
}
@set_time_limit(0);
@header('Content-Type: ' . $mime);
@ob_end_clean();
@readfile($url);
示例5: multiUpload
public function multiUpload($opath, $path, $filename, $attach = array(), $ondup = "newcopy")
{
global $_G;
/*
* 分塊上傳文件
* param $file:文件路徑(可以是url路徑,需要服務器開啟allow_url_fopen);
*/
@set_time_limit(0);
$partsize = 1024 * 1024 * 2;
//分塊大小2M
if ($attach) {
$data = $attach;
$data['size'] = $attach['filesize'];
} else {
$data = IO::getMeta($opath);
if ($data['error']) {
return $data;
}
}
if ($data['error']) {
return $data;
}
$size = $data['size'];
if (is_array($filepath = IO::getStream($opath))) {
return array('error' => $filepath['error']);
}
//exit(($size<$partsize).'===='.$size.'==='.$filepath.'===='.$path);
if ($size < $partsize) {
//獲取文件內容
$fileContent = '';
if (!($handle = fopen($filepath, 'rb'))) {
return array('error' => '文件打開錯誤');
}
while (!feof($handle)) {
$fileContent .= fread($handle, 8192);
//if(strlen($fileContent)==0) return array('error'=>'文件不存在');
}
fclose($handle);
//exit('upload');
return self::upload_by_content($fileContent, $path, $filename);
} else {
//分片上傳
$partinfo = array('ispart' => true, 'partnum' => 0, 'iscomplete' => false);
if (!($handle = fopen($filepath, 'rb'))) {
return array('error' => '文件打開錯誤');
}
//stream_set_timeout($handle,5);
$ext = strtolower(substr(strrchr($filename, '.'), 1));
$cachefile = $_G['setting']['attachdir'] . './cache/' . md5($opath) . '.' . $ext;
while (!feof($handle)) {
$fileContent .= fread($handle, 8192);
//if(strlen($fileContent)==0) return array('error'=>'文件不存在');
if (strlen($fileContent) > $partsize) {
$partinfo['partnum'] += 1;
if ($partinfo['partnum'] * $partsize >= $size) {
$partinfo['iscomplete'] = true;
}
file_put_contents($cachefile, $fileContent);
$re = self::upload($cachefile, $path, $filename, $partinfo);
if ($re['error']) {
return $re;
}
if ($partinfo['iscomplete']) {
@unlink($cachefile);
return $re;
}
$fileContent = '';
}
}
fclose($handle);
if (!empty($fileContent)) {
$partinfo['partnum'] += 1;
$partinfo['iscomplete'] = true;
file_put_contents($cachefile, $fileContent);
$re = self::upload($cachefile, $path, $filename, $partinfo);
if ($re['error']) {
return $re;
}
if ($partinfo['iscomplete']) {
@unlink($cachefile);
return $re;
}
}
}
}
示例6: multiUpload
public function multiUpload($opath, $path, $filename, $attach = array(), $ondup = "newcopy")
{
/*
* 分塊上傳文件
* param $file:文件路徑(可以是url路徑,需要服務器開啟allow_url_fopen);
*/
$partsize = 1024 * 1024 * 5;
//分塊大小2M
$data = IO::getMeta($opath);
if ($data['error']) {
return $data;
}
$size = $data['size'];
if (is_array($filepath = IO::getStream($opath))) {
return array('error' => $filepath['error']);
}
if ($size < $partsize) {
//獲取文件內容
$fileContent = '';
if (!($handle = fopen($filepath, 'rb'))) {
return array('error' => '打開文件錯誤');
}
while (!feof($handle)) {
$fileContent .= fread($handle, 8192);
}
fclose($handle);
return self::upload($fileContent, $path, $filename);
} else {
//分片上傳
$partinfo = array('ispart' => true, 'partnum' => 0, 'flag' => $path, 'iscomplete' => false);
if (!($handle = fopen($filepath, 'rb'))) {
return array('error' => '打開文件錯誤');
}
$fileContent = '';
while (!feof($handle)) {
$fileContent .= fread($handle, 8192);
if (strlen($fileContent) >= $partsize) {
$partinfo['partnum'] += 1;
if ($partinfo['partnum'] * $partsize >= $size) {
$partinfo['iscomplete'] = true;
}
if ($re = self::upload($fileContent, $path, $filename, $partinfo)) {
if ($re['error']) {
return $re;
}
if ($partinfo['iscomplete']) {
return $re;
}
}
$fileContent = '';
}
}
fclose($handle);
if (!empty($fileContent)) {
$partinfo['partnum'] += 1;
$partinfo['iscomplete'] = true;
if ($re = self::upload($fileContent, $path, $filename, $partinfo)) {
if ($re['error']) {
return $re;
}
if ($partinfo['iscomplete']) {
return $re;
}
}
}
}
}
示例7: exit
/*
* @copyright Leyun internet Technology(Shanghai)Co.,Ltd
* @license http://www.dzzoffice.com/licenses/license.txt
* @package DzzOffice
* @link http://www.dzzoffice.com
* @author zyx(zyx@dzz.cc)
*/
if (!defined('IN_DZZ')) {
exit('Access Denied');
}
if ($ismobile = helper_browser::ismobile()) {
$path = dzzdecode($_GET['path']);
IO::download($path);
exit;
}
if ($_GET['ok']) {
$path = dzzdecode($_GET['path']);
$url = IO::getStream($path, 'odconv/pdf');
@header('Content-Type:application/pdf');
@ob_end_clean();
if (getglobal('gzipcompress')) {
@ob_start('ob_gzhandler');
}
@readfile($url);
@flush();
@ob_flush();
exit;
} else {
$url = DZZSCRIPT . '?mod=document&op=pdfviewer&path=' . $_GET['path'] . '&ok=1';
include template('pdfviewer');
}
示例8: multiUpload
public function multiUpload($opath, $path, $filename, $attach = array(), $ondup = "newcopy")
{
global $_G;
@set_time_limit(0);
/*
* 分塊上傳文件
* param $file:文件路徑(可以是url路徑,需要服務器開啟allow_url_fopen);
*/
$partsize = 1024 * 1024 * 4;
//分塊大小2M
if ($attach) {
$data = $attach;
$data['size'] = $attach['filesize'];
} else {
$data = IO::getMeta($opath);
if ($data['error']) {
return $data;
}
}
$size = $data['size'];
if (is_array($filepath = IO::getStream($opath))) {
return array('error' => $filepath['error']);
}
if ($size < $partsize) {
//獲取文件內容
$fileContent = '';
if (!($handle = fopen($filepath, 'rb'))) {
return array('error' => '打開文件錯誤');
}
while (!feof($handle)) {
$fileContent .= fread($handle, 8192);
//if(strlen($fileContent)==0) return array('error'=>'文件不存在');
}
fclose($handle);
return self::upload_by_content($fileContent, $path, $filename);
} else {
//分片上傳
if (!($handle = fopen($filepath, 'rb'))) {
return array('error' => '打開文件錯誤');
}
$partinfo = array('ispart' => true);
$cachefile = $_G['setting']['attachdir'] . './cache/' . md5($opath);
while (!feof($handle)) {
file_put_contents($cachefile, fread($handle, 8192), FILE_APPEND);
}
$re = self::upload($cachefile, $path, $filename);
@unlink($cachefile);
return $re;
}
}