本文整理匯總了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!";
}