本文整理匯總了PHP中Picture::insertGetId方法的典型用法代碼示例。如果您正苦於以下問題:PHP Picture::insertGetId方法的具體用法?PHP Picture::insertGetId怎麽用?PHP Picture::insertGetId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Picture
的用法示例。
在下文中一共展示了Picture::insertGetId方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: postCreate
public function postCreate()
{
if (Auth::guest()) {
return Redirect::secure('user/login');
}
// do not use layout for this
$this->layout = null;
// check image size (must be < 10MB)
if (Input::file('image')->getSize() > 10000000) {
return Redirect::secure('picture/upload');
}
// check image type (must be (jpg, png, gif or jpeg))
if (Input::file('image')->getClientOriginalExtension() == "jpg" || Input::file('image')->getClientOriginalExtension() == "jpeg" || Input::file('image')->getClientOriginalExtension() == "png" || Input::file('image')->getClientOriginalExtension() == "gif") {
// add record to db
Input::get('isPrivate') == 1 ? $isPrivate = 1 : ($isPrivate = 0);
$id = Picture::insertGetId(array('user_id' => Input::get('userId'), 'album_id' => Input::get('albumId'), 'filename' => Input::file('image')->getClientOriginalName(), 'size' => Input::file('image')->getSize(), 'title' => strip_tags(Purifier::clean(Input::get('title'))), 'isPrivate' => $isPrivate));
// move to albums folder
$destinationPath = public_path() . "/files/" . Input::get('userId') . "/" . Input::get('albumId');
Input::file('image')->move($destinationPath, Input::file('image')->getClientOriginalName());
// redirect to uploaded picture
return Redirect::secure('picture/' . $id);
}
return Redirect::secure('picture/upload');
}