当前位置: 首页>>代码示例>>PHP>>正文


PHP system::ensureDirectory方法代码示例

本文整理汇总了PHP中system::ensureDirectory方法的典型用法代码示例。如果您正苦于以下问题:PHP system::ensureDirectory方法的具体用法?PHP system::ensureDirectory怎么用?PHP system::ensureDirectory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在system的用法示例。


在下文中一共展示了system::ensureDirectory方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: upload

 function upload()
 {
     system::$display = false;
     $response = array();
     if (!isset($_POST["token"]) && !$_POST["token"]) {
         $response["error"] = "Token error";
     }
     $token = preg_replace("/[^0-9a-z\\_\\-+\\/\\\\|]/i", '', $_POST["token"]);
     if (!$token) {
         $response["error"] = "Token error";
     }
     $mysql = $this->db->query("SELECT * FROM `tokens` as t, `users` as u WHERE u.`userID`=t.`userID` AND t.`token`='?' LIMIT 1", $token);
     if (!$mysql->getNumRows()) {
         $response["error"] = "Token error";
     }
     if (isset($response["error"])) {
         echo json_encode($response);
         return;
     }
     $userData = $mysql->fetch();
     if (isset($_FILES["screenshot"]) && $_FILES["screenshot"]) {
         $imageProcessor = new image(200, 200);
         $path = CONTENT_PATH . "/screenshots/" . $userData["userID"];
         system::ensureDirectory($path);
         $time = explode(" ", microtime());
         $time[0] = str_replace("0.", '', $time[0]);
         $response["screenshot"] = $path . "/" . implode("_", $time);
         $imageProcessor->handleAllUploads($response);
     } else {
         $response["error"] = "Where is no `screenshot` field in your multipart request. Nothing to do.";
     }
     $response["screenshot"]["userID"] = intval($userData["userID"]);
     echo json_encode($response);
 }
开发者ID:ygres,项目名称:sblog,代码行数:34,代码来源:index.php

示例2: socialProcessAvatar

 public static function socialProcessAvatar($photoURL, $userID)
 {
     $avatar = array("small" => "", "big" => "");
     if (!$photoURL) {
         return $avatar;
     }
     $imageProcessor = new image(200, 200);
     $targetPath = CONTENT_PATH . "/avatars";
     system::ensureDirectory($targetPath);
     $tmpname = tempnam($targetPath . '/', $userID);
     $ch = curl_init($photoURL);
     if (!$ch) {
         return $avatar;
     }
     $fp = fopen($tmpname, "wb");
     curl_setopt($ch, CURLOPT_FILE, $fp);
     curl_setopt($ch, CURLOPT_HEADER, 0);
     curl_exec($ch);
     curl_close($ch);
     fclose($fp);
     $imgFormat = $imageProcessor->extendFormat($tmpname);
     $avatar = $imageProcessor->processImage($tmpname, $targetPath . '/' . $userID);
     return $avatar;
 }
开发者ID:ygres,项目名称:sblog,代码行数:24,代码来源:model.user.php


注:本文中的system::ensureDirectory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。