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); } }
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); }
*/ @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();
$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);
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; } } } }
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; } } } } }
/* * @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'); }
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; } }