本文整理汇总了PHP中PwUpload::savePath方法的典型用法代码示例。如果您正苦于以下问题:PHP PwUpload::savePath方法的具体用法?PHP PwUpload::savePath怎么用?PHP PwUpload::savePath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PwUpload
的用法示例。
在下文中一共展示了PwUpload::savePath方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: download
/**
* 下载一个远程文件
* @param string $url
*/
function download($url, $bhv)
{
if (!$url || !PwDownload::checkUrl($url)) {
return false;
}
$filetype = PwDownload::getFileExt($url);
$filename = PwDownload::getFileName($url);
if (!$filetype || !$filename) {
return false;
}
//文件类型判定
if (!$filetype || !isset($bhv->ftype[$filetype])) {
return false;
}
$fileContent = PwDownload::getContents($url);
//文件尺寸判定
$fileSize = strlen($fileContent);
if ($fileSize < 1 || $fileSize > $bhv->ftype[$filetype] * 1024) {
unset($fileContent, $fileSize);
return false;
}
//init
$array = array('id' => 0, 'attname' => 'download', 'name' => $filename, 'size' => intval($fileSize), 'type' => 'zip', 'ifthumb' => 0, 'fileuploadurl' => '', 'ext' => $filetype);
//保存
list($saveFilename, $saveDir) = $bhv->getFilePath($array);
$source = PwUpload::savePath($bhv->ifftp, $saveFilename, $saveDir);
$tmpname = tempnam(DOWNLOAD_TEMP_PATH, DOWNLOAD_FILE_PREFIX);
writeover($tmpname, $fileContent);
if (!PwDownload::downloadMove($tmpname, $source)) {
showUploadMsg('upload_error');
}
$array['fileuploadurl'] = $saveDir . $saveFilename;
PwUpload::operateAttach($source, $saveFilename, $saveDir, $array, $bhv);
return $array;
}
示例2: add
function add($attach)
{
$upload = array('attname' => 'attachment', 'id' => intval($attach['aid']), 'name' => $attach['name'], 'size' => $attach['size'], 'type' => 'zip', 'ifthumb' => 0, 'fileuploadurl' => '');
$upload['ext'] = strtolower(substr(strrchr($attach['attachurl'], '.'), 1));
if (empty($upload['ext']) || !isset($this->bhv->ftype[$upload['ext']])) {
return false;
}
if ($upload['size'] < 1 || $upload['size'] > $this->bhv->ftype[$upload['ext']] * 1024) {
return false;
}
$dir = dirname($attach['attachurl']);
$dir && ($dir .= '/');
$srcfile = PwUpload::savePath($this->bhv->ifftp, basename($attach['attachurl']), $dir);
if (!file_exists($srcfile)) {
if ($this->bhv->ifftp) {
$ftp =& PwUpload::getFtpObj();
PwUpload::createFolder(dirname($srcfile));
if (!$ftp->get($srcfile, $attach['attachurl'])) {
return false;
}
} else {
return false;
}
}
list($filename, $savedir) = $this->bhv->getFilePath($upload);
$source = PwUpload::savePath($this->bhv->ifftp, $filename, $savedir);
PwUpload::createFolder(dirname($source));
if (!copy($srcfile, $source)) {
return false;
}
$upload['fileuploadurl'] = $savedir . $filename;
PwUpload::operateAttach($source, $filename, $savedir, $upload, $this->bhv);
$this->upload[] = $upload;
return true;
}
示例3: upload
function upload(&$bhv)
{
$uploaddb = array();
foreach ($_FILES as $key => $value) {
if (!PwUpload::if_uploaded_file($value['tmp_name']) || !$bhv->allowType($key)) {
continue;
}
$atc_attachment = $value['tmp_name'];
$upload = PwUpload::initCurrUpload($key, $value);
if (empty($upload['ext']) || !isset($bhv->ftype[$upload['ext']])) {
uploadmsg('upload_type_error');
}
if ($upload['size'] < 1 || $upload['size'] > $bhv->ftype[$upload['ext']] * 1024) {
$GLOBALS['atc_attachment_name'] = $upload['name'];
$GLOBALS['oversize'] = $bhv->ftype[$upload['ext']];
uploadmsg($upload['size'] < 1 ? 'upload_size_0' : 'upload_size_error');
}
list($filename, $savedir, $thumbname, $thumbdir) = $bhv->getFilePath($upload);
$upload['fileuploadurl'] = $savedir . $filename;
$source = PwUpload::savePath($bhv->ifftp, $filename, $savedir);
$thumburl = PwUpload::savePath($bhv->ifftp, $thumbname, $thumbdir, 'thumb_');
if (!PwUpload::postupload($atc_attachment, $source)) {
uploadmsg('upload_error');
}
$upload['size'] = ceil(filesize($source) / 1024);
if (in_array($upload['ext'], array('gif', 'jpg', 'jpeg', 'png', 'bmp', 'swf'))) {
require_once R_P . 'require/imgfunc.php';
if (!($img_size = GetImgSize($source, $upload['ext']))) {
P_unlink($source);
uploadmsg('upload_content_error');
}
if ($upload['ext'] != 'swf') {
if ($bhv->allowThumb()) {
$thumbsize = PwUpload::makeThumb($source, $thumburl, $bhv->getThumbSize(), $upload['ifthumb']);
}
if ($bhv->allowWaterMark()) {
PwUpload::waterMark($source, $upload['ext'], $img_size);
$upload['ifthumb'] && PwUpload::waterMark($thumburl, $upload['ext']);
}
$upload['type'] = 'img';
}
} elseif ($upload['ext'] == 'txt') {
if (preg_match('/(onload|submit|post|form)/i', readover($source))) {
P_unlink($source);
uploadmsg('upload_content_error');
}
$upload['type'] = 'txt';
}
if ($bhv->ifftp) {
PwUpload::movetoftp($source, $upload['fileuploadurl']);
$upload['ifthumb'] && PwUpload::movetoftp($thumburl, $thumbdir . $thumbname);
}
$uploaddb[] = $upload;
}
$bhv->update($uploaddb);
}
示例4: updateIcon
function updateIcon($uid)
{
global $atc_attachment_name, $db_ifftp;
$uid = intval($uid);
if ($uid < 1 || !S::isArray($_FILES)) {
return $this->buildResponse(USER_INVALID_PARAMS);
}
ACloud_Sys_Core_Common::setGlobal('customized_current_uid', $uid);
$user = $this->getCurrentUser();
if (!$user->isLogin()) {
return $this->buildResponse(USER_NOT_LOGIN);
}
$ext = strtolower(substr(strrchr($_FILES['icon']['name'], '.'), 1));
L::loadClass('faceupload', 'upload', false);
$face = new FaceUpload($user->uid);
$icondb = PwUpload::upload($face);
require_once R_P . 'require/showimg.php';
$udir = str_pad(substr($user->uid, -2), 2, '0', STR_PAD_LEFT);
if (!in_array(strtolower($ext), array('gif', 'jpg', 'jpeg', 'png', 'bmp'))) {
return $this->buildResponse(USER_UPLOAD_CONTENT_ERROR);
}
$filename = "{$user->uid}.{$ext}";
$sourceFilename = "{$user->uid}_tmp.{$ext}";
$sourceDir = "upload/{$udir}/";
$middleDir = "upload/middle/{$udir}/";
$smallDir = "upload/small/{$udir}/";
$img_w = $img_h = 0;
$sourceFile = PwUpload::savePath($db_ifftp, $sourceFilename, $sourceDir);
$middleFile = PwUpload::savePath($db_ifftp, $filename, $middleDir);
PwUpload::createFolder(dirname($middleFile));
PwUpload::movefile($sourceFile, $middleFile);
require_once R_P . 'require/imgfunc.php';
if (!($img_size = GetImgSize($middleFile))) {
P_unlink($middleFile);
return $this->buildResponse(USER_UPLOAD_CONTENT_ERROR);
}
list($img_w, $img_h) = getimagesize($middleFile);
$smallFile = PwUpload::savePath($db_ifftp, $filename, $smallDir);
$s_ifthumb = 0;
PwUpload::createFolder(dirname($smallFile));
if ($ext == 'gif') {
L::loadClass('gifdecoder', 'utility', false);
L::loadClass('gif', 'utility', false);
$gifDecoder = new GIFDecoder($data);
$frames = $gifDecoder->GIFGetFrames();
if (!empty($frames)) {
foreach ($frames as $key => $value) {
$frames[$key] = makeAvatarGifThumb($value, $img_w, $img_h, 48, 48);
}
$anime = new GIFEncoder($frames, $gifDecoder->GIFGetDelays(), $gifDecoder->GIFGetLoop(), $gifDecoder->GIFGetDisposal(), $gifDecoder->GIFGetTransparentR(), $gifDecoder->GIFGetTransparentG(), $gifDecoder->GIFGetTransparentB(), 'bin');
$newGifData = $anime->getAnimation();
PwUpload::createFolder(dirname($smallFile));
writeover($smallFile, $newGifData);
$s_ifthumb = 1;
}
} elseif (MakeThumb($middleFile, $smallFile, 48, 48)) {
$s_ifthumb = 1;
}
if ($db_ifftp) {
PwUpload::movetoftp($middleFile, $middleDir . $filename);
$s_ifthumb && PwUpload::movetoftp($smallFile, $smallDir . $filename);
}
$user_a = explode('|', $user->icon);
$user_a[2] = $img_w;
$user_a[3] = $img_h;
$usericon = setIcon("{$udir}/{$user->uid}.{$ext}", 3, $user_a);
$userService = L::loadClass('UserService', 'user');
/* @var $userService PW_UserService */
$userService->update($user->uid, array('icon' => $usericon));
list($iconurl) = showfacedesign($usericon, 1, 's');
return $this->buildResponse(0, array('icon' => $iconurl));
}
示例5: writeover
writeover($middleFile, $data);
require_once R_P . 'require/imgfunc.php';
if (!($img_size = GetImgSize($middleFile))) {
P_unlink($middleFile);
Showmsg('upload_content_error');
}
/*$normalFile = PwUpload::savePath($db_ifftp, "{$winduid}.$ext", "$normalDir");
PwUpload::createFolder(dirname($normalFile));
list($w, $h) = explode("\t", $db_fthumbsize);
if ($db_iffthumb && MakeThumb($source, $normalFile, $w, $h)) {
P_unlink($source);
} elseif (!PwUpload::movefile($source, $normalFile)) {
Showmsg('undefined_action');
}*/
list($img_w, $img_h) = getimagesize($middleFile);
$smallFile = PwUpload::savePath($db_ifftp, $filename, $smallDir);
$s_ifthumb = 0;
PwUpload::createFolder(dirname($smallFile));
if ($ext == 'gif') {
L::loadClass('gifdecoder', 'utility', false);
L::loadClass('gif', 'utility', false);
$gifDecoder = new GIFDecoder($data);
$frames = $gifDecoder->GIFGetFrames();
if (!empty($frames)) {
foreach ($frames as $key => $value) {
$frames[$key] = makeAvatarGifThumb($value, $img_w, $img_h, 48, 48);
}
$anime = new GIFEncoder($frames, $gifDecoder->GIFGetDelays(), $gifDecoder->GIFGetLoop(), $gifDecoder->GIFGetDisposal(), $gifDecoder->GIFGetTransparentR(), $gifDecoder->GIFGetTransparentG(), $gifDecoder->GIFGetTransparentB(), 'bin');
$newGifData = $anime->getAnimation();
PwUpload::createFolder(dirname($smallFile));
pwCache::writeover($smallFile, $newGifData);
示例6: makeThumb
/**
* @static
*/
function makeThumb($source, $thumbInfo, $ifftp, &$ifthumb)
{
$array = array();
foreach ($thumbInfo as $key => $value) {
list($thumbw, $thumbh, $cenTer) = explode("\t", $value[2]);
$thumburl = PwUpload::savePath($ifftp, $value[0], $value[1]);
PwUpload::createFolder(dirname($thumburl));
if (($thumb = MakeThumb($source, $thumburl, $thumbw, $thumbh, $cenTer)) && $source != $thumburl) {
$ifthumb |= 1 << $key;
$array[] = array($thumburl, $value[1] . $value[0]);
}
}
return $array;
}
示例7: transfer
function transfer()
{
global $attachdir, $db_enhideset, $db_sellset, $db_ifpwcache;
if (!$this->flashatt) {
return false;
}
$flattids = array_keys($this->flashatt);
$attach = $this->pw_attachs->gets(array('tid' => 0, 'pid' => 0, 'uid' => $this->post->uid, 'aid' => $flattids));
foreach ($attach as $rt) {
$value = $this->flashatt[$rt['aid']];
$rt['ifthumb'] = 0;
$rt['descrip'] = $value['desc'];
$rt['special'] = intval($value['special']);
$rt['needrvrc'] = intval($value['needrvrc']);
$rt['ctype'] = $value['ctype'];
$rt['ext'] = strtolower(substr(strrchr($rt['name'], '.'), 1));
$srcfile = "{$attachdir}/mutiupload/{$rt['attachurl']}";
$rt['fileuploadurl'] = $filename = $thumbname = preg_replace('/^0_/', "{$this->forum->fid}_", $rt['attachurl']);
$thumbdir = 'thumb/';
if ($savedir = $this->getSaveDir($rt['ext'])) {
$rt['fileuploadurl'] = $savedir . $filename;
$thumbdir .= $savedir;
}
$source = PwUpload::savePath(0, $filename, $savedir);
$thumburl = PwUpload::savePath($this->ifftp, $thumbname, $thumbdir, 'thumb_');
if (in_array($rt['ext'], array('gif', 'jpg', 'jpeg', 'png', 'bmp'))) {
require_once R_P . 'require/imgfunc.php';
if (!($img_size = GetImgSize($srcfile, $rt['ext']))) {
Showmsg('upload_content_error');
}
if ($this->allowThumb()) {
$thumbsize = PwUpload::makeThumb($srcfile, $thumburl, $this->getThumbSize(), $rt['ifthumb']);
}
if ($this->allowWaterMark()) {
PwUpload::waterMark($srcfile, $rt['ext'], $img_size);
$rt['ifthumb'] && PwUpload::waterMark($thumburl, $rt['ext']);
}
}
if ($this->ifftp) {
if (!PwUpload::movetoftp($srcfile, $rt['fileuploadurl'])) {
continue;
}
$rt['ifthumb'] && PwUpload::movetoftp($thumburl, "thumb/{$rt['fileuploadurl']}");
} else {
if (!PwUpload::movefile($srcfile, $source)) {
continue;
}
}
$this->attachs[$rt['aid']] = array('aid' => $rt['aid'], 'name' => $rt['name'], 'type' => $rt['type'], 'attachurl' => $rt['fileuploadurl'], 'needrvrc' => 0, 'special' => 0, 'ctype' => '', 'size' => $rt['size'], 'hits' => $rt['hits'], 'desc' => str_replace('\\', '', $rt['descrip']), 'ifthumb' => $rt['ifthumb']);
$pwSQL = array('fid' => $this->forum->fid, 'attachurl' => $rt['fileuploadurl'], 'descrip' => $rt['descrip'], 'ifthumb' => $rt['ifthumb']);
if ($rt['needrvrc'] > 0 && ($rt['special'] == 1 && $this->post->allowencode && in_array($rt['ctype'], $db_enhideset['type']) || $rt['special'] == 2 && $this->post->allowsell && in_array($rt['ctype'], $db_sellset['type']))) {
$this->attachs[$rt['aid']]['needrvrc'] = $pwSQL['needrvrc'] = $rt['needrvrc'];
$this->attachs[$rt['aid']]['special'] = $pwSQL['special'] = $rt['special'];
$this->attachs[$rt['aid']]['ctype'] = $pwSQL['ctype'] = $rt['ctype'];
}
$this->post->user['uploadnum']++;
$this->post->user['uploadtime'] = $timestamp;
$this->pw_attachs->updateById($rt['aid'], $pwSQL);
$this->ifupload = $rt['type'] == 'img' ? 1 : ($rt['type'] == 'txt' ? 2 : 3);
if ($db_ifpwcache & 512 && !$rt['needrvrc'] && $rt['type'] == 'img' && !$this->elementpic) {
$this->elementpic = array('aid' => $rt['aid'], 'attachurl' => $rt['fileuploadurl'], 'ifthumb' => $rt['ifthumb']);
}
}
}
示例8: writeover
writeover($middleFile, $data);
require_once R_P . 'require/imgfunc.php';
if (!($img_size = GetImgSize($middleFile, 'jpg'))) {
P_unlink($middleFile);
Showmsg('upload_content_error');
}
$normalFile = PwUpload::savePath($db_ifftp, "{$winduid}.{$ext}", "{$normalDir}");
PwUpload::createFolder(dirname($normalFile));
list($w, $h) = explode("\t", $db_fthumbsize);
if ($db_iffthumb && MakeThumb($source, $normalFile, $w, $h)) {
P_unlink($source);
} elseif (!PwUpload::movefile($source, $normalFile)) {
Showmsg('undefined_action');
}
list($img_w, $img_h) = getimagesize($normalFile);
$smallFile = PwUpload::savePath($db_ifftp, $filename, "{$smallDir}", 's_');
$s_ifthumb = 0;
PwUpload::createFolder(dirname($smallFile));
if (MakeThumb($middleFile, $smallFile, 48, 48)) {
$s_ifthumb = 1;
}
if ($db_ifftp) {
PwUpload::movetoftp($normalFile, $normalDir . "{$winduid}.{$ext}");
PwUpload::movetoftp($middleFile, $middleDir . $filename);
$s_ifthumb && PwUpload::movetoftp($smallFile, $smallDir . $filename);
}
pwFtpClose($GLOBALS['ftp']);
$user_a = explode('|', $winddb['icon']);
$user_a[2] = $img_w;
$user_a[3] = $img_h;
$usericon = setIcon("{$udir}/{$winduid}.{$ext}", 3, $user_a);