本文整理汇总了PHP中PwUpload::createFolder方法的典型用法代码示例。如果您正苦于以下问题:PHP PwUpload::createFolder方法的具体用法?PHP PwUpload::createFolder怎么用?PHP PwUpload::createFolder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PwUpload
的用法示例。
在下文中一共展示了PwUpload::createFolder方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: makeThumb
public function makeThumb(PwImage $image, $thumbInfo, $store)
{
$quality = Wekit::C('attachment', 'thumb.quality');
foreach ($thumbInfo as $key => $value) {
$thumburl = $store->getAbsolutePath($value[0], $value[1]);
PwUpload::createFolder(dirname($thumburl));
$result = $image->makeThumb($thumburl, $value[2], $value[3], $quality, $value[4], $value[5]);
if ($result === true && $image->filename != $thumburl) {
$this->ifthumb |= 1 << $key;
$this->_thumb[] = array($thumburl, $value[1] . $value[0]);
}
}
}
示例3: 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));
}
示例4: defaultAvatar
public function defaultAvatar($uid, $type = 'face')
{
Wind::import('LIB:upload.PwUpload');
$_avatar = array('.jpg' => '_big.jpg', '_middle.jpg' => '_middle.jpg', '_small.jpg' => '_small.jpg');
$defaultBanDir = Wind::getRealDir('RES:') . 'images/face/';
$store = Wind::getComponent('storage');
$fileDir = 'avatar/' . Pw::getUserDir($uid) . '/';
foreach ($_avatar as $des => $org) {
$toPath = $store->getAbsolutePath($uid . $des, $fileDir);
$fromPath = $defaultBanDir . $type . $org;
PwUpload::createFolder(dirname($toPath));
PwUpload::copyFile($fromPath, $toPath);
$store->save($toPath, $fileDir . $uid . $des);
}
return true;
}
示例5: list
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);
$s_ifthumb = 1;
}
} elseif (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;
示例6: downloadMove
function downloadMove($tmp_name, $filename)
{
if (strpos($filename, '..') !== false || strpos($filename, '.php.') !== false || eregi("\\.php\$", $filename)) {
exit('illegal file type!');
}
PwUpload::createFolder(dirname($filename));
if (@rename($tmp_name, $filename)) {
@chmod($filename, 0777);
return true;
} elseif (@copy($tmp_name, $filename)) {
@chmod($filename, 0777);
@unlink($tmp_name);
return true;
} elseif (is_readable($tmp_name)) {
pwCache::writeover($filename, readover($tmp_name));
if (file_exists($filename)) {
@chmod($filename, 0777);
@unlink($tmp_name);
return true;
}
}
return false;
}
示例7: restore_avatar
/**
* 初始化用户头像
* @param int $uid
* @param string $url 腾讯头像地址
*/
function restore_avatar($uid, $url)
{
$store = Wind::getComponent('storage');
Wind::import('SRV:upload.PwUpload');
Wind::import('LIB:image.PwImage');
$fileDir = sprintf('avatar/%s/', Pw::getUserDir($uid));
$_avatar = array('.jpg' => 200, '_middle.jpg' => 120, '_small.jpg' => 50);
$file = tempnam(sys_get_temp_dir(), 'avatar');
$img = httpget($url);
file_put_contents($file, $img);
$img = new PwImage($file);
$thumb = new PwImageThumb($img);
foreach ($_avatar as $des => $size) {
$toPath = $store->getAbsolutePath($uid . $des, $fileDir);
PwUpload::createFolder(dirname($toPath));
if ($size < 100) {
$thumb->setWidth($size);
$thumb->setHeight($size);
$thumb->setDstFile($toPath);
$thumb->execute();
} else {
copy($file, $toPath);
}
}
Wind::import('SRV:upload.action.PwAvatarUpload');
Wind::import('SRV:upload.PwUpload');
PwSimpleHook::getInstance('update_avatar')->runDo($uid);
@unlink($file);
return true;
}
示例8: createFolder
/**
* @static
*/
function createFolder($path)
{
if (!is_dir($path)) {
PwUpload::createFolder(dirname($path));
@mkdir($path);
@chmod($path, 0777);
@fclose(@fopen($path . '/index.html', 'w'));
@chmod($path . '/index.html', 0777);
}
}
示例9: date
$savedir .= 'Day_' . date('ymd') . '/';
} elseif ($o_mkdir == '3') {
$savedir .= 'Cyid_' . $selaid . '/';
} else {
$savedir .= 'Mon_' . date('ym') . '/';
}
$lastphoto = '';
$i = 1;
$photos = array();
$query = $db->query("SELECT * FROM pw_cnphoto WHERE aid=" . S::sqlEscape($aid) . ' AND pid IN(' . S::sqlImplode($selid) . ')');
while ($rt = $db->fetch_array($query)) {
if (file_exists($attachdir . '/' . $rt['path'])) {
$ext = strtolower(substr(strrchr($rt['path'], '.'), 1));
$prename = randstr(4) . $timestamp . substr(md5($timestamp . $i++ . randstr(8)), 10, 15);
$filename = $selaid . "_{$prename}." . $ext;
PwUpload::createFolder($attachdir . '/' . $savedir);
$ifthumb = 0;
if (!@copy($attachdir . '/' . $rt['path'], $attachdir . '/' . $savedir . $filename)) {
continue;
}
if ($rt['ifthumb']) {
$lastpos = strrpos($rt['path'], '/') + 1;
$path = $attachdir . '/' . substr($rt['path'], 0, $lastpos) . 's_' . substr($rt['path'], $lastpos);
if (copy($path, $attachdir . '/' . $savedir . 's_' . $filename)) {
$ifthumb = 1;
}
}
$path = $savedir . $filename;
} else {
$path = $rt['path'];
$ifthumb = $rt['ifthumb'];
示例10: _defaultAvatar
private function _defaultAvatar($uid, $type = 'face')
{
Wind::import('LIB:upload.PwUpload');
$_avatar = array('.jpg' => '_big.jpg', '_middle.jpg' => '_middle.jpg', '_small.jpg' => '_small.jpg');
$defaultBanDir = Wind::getRealDir('ROOT:') . 'res/images/face/';
$fileDir = 'avatar/' . Pw::getUserDir($uid) . '/';
$attachPath = Wind::getRealDir('ROOT:') . 'windid/attachment/';
foreach ($_avatar as $des => $org) {
$toPath = $attachPath . $fileDir . $uid . $des;
$fromPath = $defaultBanDir . $type . $org;
PwUpload::createFolder(dirname($toPath));
PwUpload::copyFile($fromPath, $toPath);
}
return true;
}