本文整理汇总了PHP中mk_dir函数的典型用法代码示例。如果您正苦于以下问题:PHP mk_dir函数的具体用法?PHP mk_dir怎么用?PHP mk_dir使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mk_dir函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: delByRoleId
/**
* 根据角色ID删除记录
*
* @param int $role_id 角色ID
* @return bool
*/
public function delByRoleId($role_id)
{
$this->where("roleid={$role_id}")->delete();
del_dir($this->_cache_path);
mk_dir($this->_cache_path, 0755);
return true;
}
示例2: upload
/**
* 处理$_FILES上传的文件,返回文件本地路径
* @param string $name 上传表单名
* @param string $UploadDir 上传子目录
* @param boolean $datedir 是否采用分日期子目录
* @return boolean
*/
function upload($name, $UploadDir = 'upload', $datedir = true)
{
if (empty($_FILES) || !isset($_FILES[$name])) {
return false;
}
if ($_FILES[$name]['name'] != '') {
$file = new UploadFile();
$file->Path = FUN_ROOT;
$file->UploadDir = $UploadDir;
if ($datedir) {
$file->UploadDir .= date('/Ym');
}
if (!is_dir(mk_dir($file->Path . $file->UploadDir))) {
return false;
}
$filename = $file->uploading($name);
if ($file->Uploaded) {
//$filename = basename($filename);
return $filename;
} else {
print_r($file->Err);
return false;
}
}
}
示例3: init_app
public function init_app($user_info)
{
$list = $this->sql->get();
$new_user_app = $this->config['setting_system']['new_user_app'];
$default = explode(',', $new_user_app);
$info = array();
foreach ($default as $key) {
$info[$key] = $list[$key];
}
$desktop = USER_PATH . $user_info['name'] . '/home/desktop/';
mk_dir($desktop);
foreach ($info as $key => $data) {
if (!is_array($data)) {
continue;
}
$path = iconv_system($desktop . $key . '.oexe');
unset($data['name']);
unset($data['desc']);
unset($data['group']);
file_put_contents($path, json_encode($data));
}
$user_info['status'] = 1;
$member = new fileCache(USER_SYSTEM . 'member.php');
$member->update($user_info['name'], $user_info);
}
示例4: upload
public function upload($allowExts = "jpg,gif,png,jpeg", $savePath = "Upload", $other_param = array())
{
class_exists("UploadFile") or import("ORG.Net.UploadFile");
$upload = new UploadFile();
// 实例化上传类
$upload->allowExts = explode(",", $allowExts);
// 设置附件上传类型
$savePath = $savePath == "/" ? "Upload" : trim($savePath, "/");
$upload->savePath = ROOT_PATH . "/" . $savePath . "/";
// 设置附件上传目录
if (!is_dir($upload->savePath)) {
mk_dir($upload->savePath);
}
$other_key = array("maxSize" => 3145728, "saveRule" => "uniqid", "hashType" => null, "autoCheck" => null, "uploadReplace" => null, "allowTypes" => null, "thumb" => null, "thumbMaxWidth" => null, "thumbMaxHeight" => null, "thumbPrefix" => null, "thumbSuffix" => null, "thumbPath" => null, "thumbFile" => null, "thumbRemoveOrigin" => null, "autoSub" => true, "subType" => "date", "dateFormat" => "Ym", "hashLevel" => 1);
foreach ($other_key as $key => $val) {
if (isset($other_param[$key])) {
$upload->{$key} = $other_param[$key];
} elseif ($val !== null) {
$upload->{$key} = $val;
}
}
if (!$upload->upload()) {
// 上传错误 提示错误信息
$result = array("status" => false, "Msg" => $upload->getErrorMsg(), "info" => null);
} else {
// 上传成功 获取上传文件信息
$result = array("status" => true, "Msg" => "上传成功", "info" => $upload->getUploadFileInfo());
}
return $result;
}
示例5: detail
/**
* 快递查询
*/
public function detail()
{
$data['id'] = $_GET['id'];
$vo = $this->db->where($data)->find();
$this->assign('vo', $vo);
if (!$vo) {
$this->error('物流信息不存在');
}
$dir = get_dir($vo['id']);
if (file_exists(C('DATA_CACHE_PATH') . '/delivery/' . $dir . '/list.php')) {
$list = (include C('DATA_CACHE_PATH') . '/delivery/' . $dir . '/list.php');
} else {
include C('PUBLIC_INCLUDE') . "kuaidi.class.php";
$kuaidi = new kuaidi();
$list = $kuaidi->query($vo['shipping_code'], $vo['shipping_no']);
krsort($list['data']);
mk_dir(C('DATA_CACHE_PATH') . '/delivery/');
if ($list['state'] == 3) {
mk_dir(C('DATA_CACHE_PATH') . '/delivery/' . $dir . '/');
F('list', $list, C('DATA_CACHE_PATH') . '/delivery/' . $dir . '/');
}
}
if ($list) {
$list['count'] = count($list['data']);
} else {
$list['message'] = $kuaidi->error;
}
if (!$list) {
$this->error($kuaidi->getError());
} else {
$result['data'] = $list;
$result['notice'] = '查询成功';
ajaxSucReturn($result);
}
}
示例6: getAccessToken
private function getAccessToken() {
$path = $this->cacheDir.'/access_token.json';
$status = file_exists($path);
if($status){
$data = json_decode(file_get_contents($path),1);
}else{
mk_dir($this->cacheDir);
}
if ($status || $data['expire_time'] < time()) {
$url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=$this->appId&secret=$this->appSecret";
$res = json_decode($this->httpGet($url));
$access_token = $res->access_token;
if ($access_token) {
$data['expire_time'] = time() + 7000;
$data['access_token'] = $access_token;
file_put_contents($path,json_encode($data));
//cookie('wx_access_token',json_encode($data),7200);
/*$fp = fopen("access_token.json", "w");
fwrite($fp, json_encode($data));
fclose($fp);*/
}
} else {
$access_token = $data->access_token;
}
return $access_token;
}
示例7: copydir
function copydir($source, $destination)
{
$source = dirpath($source);
$destination = dirpath($destination);
$result = true;
if (!is_dir($source)) {
//读取源目录
msg("源目录名称错误", 0);
}
if (!is_dir($destination)) {
//读取目标目录
if (!mk_dir($destination)) {
msg("无法创建目标目录", 0);
}
}
$handle = opendir($source);
//取得目录的句柄
while (($file = readdir($handle)) !== false) {
if ($file != '.' && $file != '..') {
$src = $source . "/" . $file;
//源文件路径
$dtn = $destination . "/" . $file;
//目标文件路径
if (is_dir($src)) {
copydir($src, $dtn);
} else {
copyfile($src, $dtn);
}
//msg($src.'--->'.$dtn.'<br>');
}
}
closedir($handle);
return $result;
}
示例8: _upload
public function _upload($module, $path, $thumb, $width, $height)
{
$module = $module = "" ? 'file' : $module;
//未知模块将存入file文件夹
switch ($module) {
case 'img':
$path = C(ATTACHPATH) . '/img/' . $path . '/';
break;
default:
$path = C(ATTACHPATH) . '/file/' . $path . '/';
}
if (!is_dir($path)) {
mk_dir($path);
}
import("ORG.Net.UploadFile");
$upload = new UploadFile();
$upload->maxSize = C(ATTACHSIZE);
$upload->allowExts = C(ATTACHEXT);
$upload->savePath = $path;
$upload->saveRule = 'uniqid';
isset($thumb) ? $upload->thumb = $thumb : ($upload->thumb = C(ATTACH));
isset($width) ? $upload->thumbMaxWidth = $width : ($upload->thumbMaxWidth = C(THUMBMAXWIDTH));
isset($height) ? $upload->thumbMaxHeight = $height : ($upload->thumbMaxHeight = C(THUMBMAXHEIGHT));
$upload->thumbSuffix = C(THUMBSUFFIX);
//$upload->thumbMaxWidth =C(THUMBMAXWIDTH);
//$upload->thumbMaxHeight =C(THUMBMAXHEIGHT);
if (!$upload->upload()) {
//捕获上传异常
return $this->error($upload->getErrorMsg());
} else {
//上传成功
return $upload->getUploadFileInfo();
}
}
示例9: Set
/**
* 设置缓存
*/
public function Set(){
$name = $_POST['name'];
$value = json_decode($_POST['json_data'],true);
$expire = $_POST['expire'] ? $_POST['expire'] : C('DATA_CACHE_TIME');
if(C('DATA_CACHE_TYPE')=='Memcache'){
$expire = $expire==-1 ? 0 : $expire;
$name = $_POST['module'].':'.$_POST['name'];
}
$expire = $_POST['expire'] ? $_POST['expire'] : 0;
$dir = $_POST['dir'] ? $_POST['dir'] : '';
$options['temp'] = C('DATA_CACHE_PATH').$dir;
//创建目录
if(C('DATA_CACHE_TYPE')=='File')mk_dir(C('DATA_CACHE_PATH').$dir);
$options['filename'] = $name;
$cache = new Cache();
$cache =$cache->connect(C('DATA_CACHE_TYPE'),$options);
$cache->getInstance();
$result = $cache->set($name,$value,$expire);
if($_POST['from']=='self'){
return;
}
if($result){
$msg['error_code'] = 0;
}else{
$msg['error_code'] = 8002;
}
echo json_encode($msg);exit;
}
示例10: flash_upload_insert
public function flash_upload_insert()
{
//dump($_FILES['Filedata']);exit;
if (!isset($_POST['sessid'])) {
exit;
} else {
session_id($_POST['sessid']);
}
$name = uniqid();
$msg['ok'] = 'yes';
$path = C('IMG_ROOT') . date('Y') . '/' . date('m') . '/' . date('d') . '/';
mk_dir($path);
$array = explode('.', $_FILES['Filedata']['name']);
$type = array_pop($array);
$up_name = array_shift($array);
move_uploaded_file($_FILES['Filedata']['tmp_name'], $path . $name . '.' . $type);
$msg['file_url'] = C('IMG_URL') . date('Y') . '/' . date('m') . '/' . date('d') . '/' . $name . '.' . $type;
$msg['file_name'] = $up_name;
$msg['text'] = '<a href="' . C('IMG_URL') . date('Y') . '/' . date('m') . '/' . date('d') . '/' . $name . '.' . $type . '" target="_blank">' . $up_name . '</a>';
/*
//添加附件信息
$model = M('attachments');
$add_data['source'] = $_POST['doaction'];
$add_data['filename'] = $up_name;
$add_data['title'] = $up_name;
$add_data['type'] = $_FILES['Filedata']['type'];
$add_data['size'] = $_FILES['Filedata']['size'];
$add_data['filepath'] = C('IMG_URL').date('Y').'/'.date('m').'/'.date('d').'/'.$name.'.'.$type;
$add_data['hash'] = $_POST['hash'];
$add_data['size'] = $_FILES['Filedata']['size'];
$add_data['user_id'] = $_SESSION[C('USER_AUTH_KEY')] ? $_SESSION[C('USER_AUTH_KEY')] : 0;
*/
echo json_encode($msg);
exit;
}
示例11: upload
function upload($upload, $target = './', $exts = 'jpg,gif,torrent,zip,rar,7z,doc,docx,xls,xlsx,ppt,pptx,mp3,wma,swf,flv,txt', $size = 20, $rename = '')
{
mk_dir($target);
if (is_array($upload['name'])) {
$return = array();
foreach ($upload["name"] as $k => $v) {
if (!empty($upload['name'][$k])) {
$ext = get_ext($upload['name'][$k]);
if (strpos($exts, $ext) !== false && $upload['size'][$k] < $size * 1024 * 1024) {
$name = empty($rename) ? upload_name($ext) : upload_rename($rename, $ext);
if (upload_move($upload['tmp_name'][$k], $target . $name)) {
$return[] = $name;
}
}
}
}
return $return;
} else {
$return = '';
if (!empty($upload['name'])) {
$ext = get_ext($upload['name']);
if (strpos($exts, $ext) !== false && $upload['size'] < $size * 1024 * 1024) {
$name = empty($rename) ? upload_name($ext) : upload_rename($rename, $ext);
if (upload_move($upload['tmp_name'], $target . $name)) {
$return = $name;
}
}
}
}
return $return;
}
示例12: write_content_to_file_with_uid
function write_content_to_file_with_uid($tuid, $content)
{
// 生成目录
$path = DATA_PATH . "/" . $tuid . "/queue/";
$file = "";
$succ = FALSE;
// hash目录
$path .= date('Ymd') . "/";
if (!file_exists($path)) {
// 创建目录
if (mk_dir($path) !== TRUE) {
log_error('fail', 'mkdir {$path} fail');
return "";
}
}
$seq = 0;
for ($i = 0; $i < 100; $i++, $seq++) {
$file = $path . "/" . time() . "." . $seq;
if (file_exists($file)) {
continue;
}
$succ = file_put_contents($file, $content);
if ($succ === FALSE) {
continue;
} else {
break;
}
}
$file = str_replace(DATA_PATH, DATA_HOST, $file);
return $file;
}
示例13: _upload
/**
+------------------------------------------------------------------------------
* 公共 文件上传方法
+------------------------------------------------------------------------------
* $path string 上传路径
* $maxsize int 上传文件最大值
* $thumb boolean 是否生成缩略图
* $width int 缩略图最大宽度
* $height int 缩略图最大高度
* $autosub boolean 是否使用子目录保存文件
+------------------------------------------------------------------------------
*/
public function _upload($path, $thumb = false, $width, $height, $autosub = false, $maxsize)
{
import("ORG.Net.UploadFile");
$upload = new UploadFile();
isset($maxsize) ? $upload->maxSize = $maxsize : ($upload->maxSize = 1048576);
//1M
isset($path) ? $upload->savePath = $savepath = "./Attachments/" . $path . "/" : ($upload->savePath = "./Attachments/Others/");
if (!is_dir($savepath)) {
@mk_dir($savepath);
}
$upload->allowExts = explode(',', 'gif,png,jpg,jpeg');
if ($thumb) {
$upload->thumb = true;
$upload->thumbPrefix = '';
$upload->thumbSuffix = '_thumb';
isset($wideh) ? $upload->thumbMaxWidth = $width : ($upload->thumbMaxWidth = "300");
isset($height) ? $upload->thumbMaxHeight = $height : ($upload->thumbMaxHeight = "400");
}
if ($autosub) {
$upload->autoSub = true;
$upload->subType = 'date';
$upload->saveRule = time;
$upload->dateFormat = 'Y/m/d';
}
if (!$upload->upload()) {
$this->error($upload->getErrorMsg());
} else {
$imginfo = $upload->getUploadFileInfo();
$imginfo = $imginfo[0]['savename'];
}
return $imginfo;
}
示例14: getSavePath
function getSavePath()
{
$savePath = SITE_PATH . '/data/uploads/avatar/' . $this->uid;
if (!file_exists($savePath)) {
mk_dir($savePath);
}
return $savePath;
}
示例15: getSaveTempPath
function getSaveTempPath()
{
$savePath = SITE_PATH . '/data/uploads/temp';
if (!file_exists($savePath)) {
mk_dir($savePath);
}
return $savePath;
}