本文整理汇总了PHP中UserList::addPhoto方法的典型用法代码示例。如果您正苦于以下问题:PHP UserList::addPhoto方法的具体用法?PHP UserList::addPhoto怎么用?PHP UserList::addPhoto使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserList
的用法示例。
在下文中一共展示了UserList::addPhoto方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: respond
$output = json_encode($result, JSON_PRETTY_PRINT);
echo $output;
});
respond('POST', '/[:userid]/[:id]', function ($request, $response) {
$userid = $request->userid;
$listitem = $request->id;
$filedata = $request->param('filedata');
$filedata = base64_decode($filedata);
if (strlen($filedata) > 50) {
$tmp = "" . tempnam("../list-uploads/", "process-me-" . $userid . "-");
$image = fopen($tmp, "w") or die("Unable to open file!");
fwrite($image, $filedata);
fclose($image);
$list = new UserList();
$filename = $tmp;
$result = $list->addPhoto($userid, $filename, $listitem);
} else {
http_response_code(400);
}
});
});
// Note photo, not photos
with('/api/photo', function () {
// Get the global photo list
respond('POST', '/[:photoid]/like', function ($request, $response) {
list($sessionuserid, $skey) = validateUserSession($request);
if ($sessionuserid) {
$photoid = $request->photoid;
list($result_code, $result) = User::likePhoto($sessionuserid, $photoid);
http_response_code($result_code);
} else {
示例2: dirname
You should have received a copy of the GNU General Public License and
the GNU Affero General Public License along with this program.
If not, see <http://www.gnu.org/licenses/>.
*/
require_once 'database.php';
require 'data/User.php';
require 'data/List.php';
require_once 'templating.php';
if ($auth) {
if (isset($_FILES['list-image'])) {
$path = dirname($_SERVER['PHP_SELF']) . '/list-uploads/foo.gif';
$tmp = "" . tempnam("./list-uploads/", "process-me-" . $userid . "-");
if (move_uploaded_file($_FILES["list-image"]["tmp_name"], $tmp)) {
$list = new UserList();
$filename = $tmp;
$id = $_POST['id'];
$result = $list->addPhoto($userid, $filename, $id);
header('Location: my-list.php?msg=1');
} else {
echo "<h1>Error: " . $_FILES["list-image"]["error"] . "</h1>";
echo "Make sure your server can support a file this large as a PHP upload.";
}
} else {
echo "File naming error! Please try again. This is a bug we're aware of";
}
} else {
echo "Authentication error!";
}