本文整理汇总了PHP中ImageHandler::uploadImage方法的典型用法代码示例。如果您正苦于以下问题:PHP ImageHandler::uploadImage方法的具体用法?PHP ImageHandler::uploadImage怎么用?PHP ImageHandler::uploadImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImageHandler
的用法示例。
在下文中一共展示了ImageHandler::uploadImage方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save_settings
public function save_settings()
{
$input = Input::all();
$settings = Setting::first();
$demo_mode = Input::get('demo_mode');
$enable_https = Input::get('enable_https');
if (empty($demo_mode)) {
$input['demo_mode'] = 0;
}
if (empty($enable_https)) {
$input['enable_https'] = 0;
}
if (Input::hasFile('logo')) {
$input['logo'] = ImageHandler::uploadImage(Input::file('logo'), 'settings');
} else {
$input['logo'] = $settings->logo;
}
if (Input::hasFile('favicon')) {
$input['favicon'] = ImageHandler::uploadImage(Input::file('favicon'), 'settings');
} else {
$input['favicon'] = $settings->favicon;
}
$settings->update($input);
return Redirect::to('admin/settings')->with(array('note' => 'Successfully Updated Site Settings!', 'note_type' => 'success'));
}
示例2: update
public function update($username)
{
$input = array_except(Input::all(), '_method');
$input['username'] = str_replace('.', '-', $input['username']);
$user = User::where('username', '=', $username)->first();
if (Auth::user()->id == $user->id) {
if (Input::hasFile('avatar')) {
$input['avatar'] = ImageHandler::uploadImage(Input::file('avatar'), 'avatars');
} else {
$input['avatar'] = $user->avatar;
}
if ($input['password'] == '') {
$input['password'] = $user->password;
} else {
$input['password'] = Hash::make($input['password']);
}
if ($user->username != $input['username']) {
$username_exist = User::where('username', '=', $input['username'])->first();
if ($username_exist) {
return Redirect::to('user/' . $user->username . '/edit')->with(array('note' => 'Sorry That Username is already in Use', 'note_type' => 'error'));
}
}
$user->update($input);
return Redirect::to('user/' . $user->username . '/edit')->with(array('note' => 'Successfully Updated User Info', 'note_type' => 'success'));
}
return Redirect::to('user/' . Auth::user()->username . '/edit ')->with(array('note' => 'Sorry, there seems to have been an error when updating the user info', 'note_type' => 'error'));
}
示例3: update
/**
* Update the specified resource in storage.
*
* @param int $id
* @return Response
*/
public function update()
{
$data = Input::all();
$id = $data['id'];
$post = Post::findOrFail($id);
$validator = Validator::make($data, Post::$rules);
if ($validator->fails()) {
return Redirect::back()->withErrors($validator)->withInput();
}
if (empty($data['image'])) {
unset($data['image']);
} else {
$data['image'] = ImageHandler::uploadImage($data['image'], 'images');
}
$post->update($data);
return Redirect::to('admin/posts/edit' . '/' . $id)->with(array('note' => 'Successfully Updated Post!', 'note_type' => 'success'));
}
示例4: update
public function update()
{
$input = Input::all();
$id = $input['id'];
$user = User::find($id);
if (Input::hasFile('avatar')) {
$input['avatar'] = ImageHandler::uploadImage(Input::file('avatar'), 'avatars');
} else {
$input['avatar'] = $user->avatar;
}
if (empty($input['active'])) {
$input['active'] = 0;
}
if ($input['password'] == '') {
$input['password'] = $user->password;
} else {
$input['password'] = Hash::make($input['password']);
}
$user->update($input);
return Redirect::to('admin/user/edit/' . $id)->with(array('note' => 'Successfully Updated User Settings', 'note_type' => 'success'));
}
示例5: update
public function update($id)
{
$input = array_except(Input::all(), '_method');
$input['username'] = str_replace('.', '-', $input['username']);
$validation = Validator::make($input, User::$update_rules);
if ($validation->passes()) {
$user = $this->user->find($id);
if (Input::hasFile('avatar')) {
$input['avatar'] = ImageHandler::uploadImage(Input::file('avatar'), 'avatars');
} else {
$input['avatar'] = $user->avatar;
}
if ($input['password'] == '') {
$input['password'] = $user->password;
} else {
$input['password'] = Hash::make($input['password']);
}
if ($user->username != $input['username']) {
$username_exist = User::where('username', '=', $input['username'])->first();
if ($username_exist) {
return Redirect::to('user/' . $user->username)->with(array('note' => Lang::get('lang.username_in_use'), 'note_type' => 'error'));
}
}
$user->update($input);
return Redirect::to('user/' . $user->username)->with(array('note' => Lang::get('lang.update_user'), 'note_type' => 'success'));
}
return Redirect::to('user/' . Auth::user()->username)->with(array('note' => Lang::get('lang.validation_errors'), 'note_type' => 'error'));
}
示例6: update_settings
public function update_settings()
{
$input = Input::all();
$settings = Setting::first();
if (isset($input['auto_approve_posts'])) {
$input['auto_approve_posts'] = 1;
} else {
$input['auto_approve_posts'] = 0;
}
$settings->auto_approve_posts = htmlspecialchars($input['auto_approve_posts']);
if (isset($input['user_registration'])) {
$input['user_registration'] = 1;
} else {
$input['user_registration'] = 0;
}
$settings->user_registration = htmlspecialchars($input['user_registration']);
if (isset($input['infinite_scroll'])) {
$input['infinite_scroll'] = 1;
} else {
$input['infinite_scroll'] = 0;
}
if (isset($input['random_bar_enabled'])) {
$input['random_bar_enabled'] = 1;
} else {
$input['random_bar_enabled'] = 0;
}
if (isset($input['media_description'])) {
$input['media_description'] = 1;
} else {
$input['media_description'] = 0;
}
if (isset($input['enable_watermark'])) {
$input['enable_watermark'] = 1;
} else {
$input['enable_watermark'] = 0;
}
if (isset($input['pages_in_menu'])) {
$input['pages_in_menu'] = 1;
} else {
$input['pages_in_menu'] = 0;
}
if (isset($input['infinite_load_btn'])) {
$input['infinite_load_btn'] = 1;
} else {
$input['infinite_load_btn'] = 0;
}
if (isset($input['captcha'])) {
$input['captcha'] = 1;
} else {
$input['captcha'] = 0;
}
$settings->captcha = htmlspecialchars($input['captcha']);
$settings->captcha_public_key = htmlspecialchars($input['captcha_public_key']);
$settings->captcha_private_key = htmlspecialchars($input['captcha_private_key']);
$settings->pages_in_menu = htmlspecialchars($input['pages_in_menu']);
$settings->pages_in_menu_text = htmlspecialchars($input['pages_in_menu_text']);
$settings->infinite_load_btn = htmlspecialchars($input['infinite_load_btn']);
$settings->enable_watermark = htmlspecialchars($input['enable_watermark']);
if (Input::hasFile('watermark_image')) {
$settings->watermark_image = ImageHandler::uploadImage(Input::file('watermark_image'), 'settings');
}
$settings->watermark_position = htmlspecialchars($input['watermark_position']);
$settings->watermark_offset_x = htmlspecialchars($input['watermark_offset_x']);
$settings->watermark_offset_y = htmlspecialchars($input['watermark_offset_y']);
$settings->infinite_scroll = htmlspecialchars($input['infinite_scroll']);
$settings->random_bar_enabled = htmlspecialchars($input['random_bar_enabled']);
$settings->media_description = htmlspecialchars($input['media_description']);
if (Input::hasFile('logo')) {
$settings->logo = ImageHandler::uploadImage(Input::file('logo'), 'settings');
}
if (Input::hasFile('favicon')) {
$settings->favicon = ImageHandler::uploadImage(Input::file('favicon'), 'settings');
}
$settings->website_name = htmlspecialchars($input['website_name']);
$settings->website_description = htmlspecialchars($input['website_description']);
$settings->primary_color = htmlspecialchars($input['primary_color']);
$settings->secondary_color = htmlspecialchars($input['secondary_color']);
$settings->like_icon = htmlspecialchars($input['like_icon']);
$settings->fb_key = htmlspecialchars($input['fb_key']);
$settings->fb_secret_key = htmlspecialchars($input['fb_secret_key']);
$settings->facebook_page_id = htmlspecialchars($input['facebook_page_id']);
$settings->google_key = htmlspecialchars($input['google_key']);
$settings->google_secret_key = htmlspecialchars($input['google_secret_key']);
$settings->google_page_id = htmlspecialchars($input['google_page_id']);
$settings->twitter_page_id = htmlspecialchars($input['twitter_page_id']);
$settings->analytics = stripslashes($input['analytics']);
$settings->system_email = $input['system_email'];
$settings->save();
$data = array('settings' => $settings);
$notification_text = Lang::get('lang.update_settings_success');
return Redirect::to('admin#settings')->with(array('note' => $notification_text, 'note_type' => 'success'));
}
示例7: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
if (!Auth::guest() && Auth::user()->active) {
$input = Input::all();
$validation = Validator::make($input, Media::$rules);
$valid_media = false;
if (isset($input['pic_url']) && !empty($input['pic_url'])) {
$valid_media = true;
} else {
if (isset($input['img_url']) && $input['img_url'] != '') {
$valid_media = true;
} else {
if (isset($input['vid']) && $input['vid'] != '') {
$valid_media = true;
}
}
}
if ($validation->passes() && $valid_media) {
if (isset($input['pic'])) {
if (isset($input['img_url']) && $input['img_url'] != '') {
$input['pic_url'] = ImageHandler::uploadImage($input['img_url'], 'images', Helper::slugify($input['title']), 'url');
} else {
if (isset($input['pic_url'])) {
$input['pic_url'] = ImageHandler::uploadImage(Input::file('pic_url'), 'images');
}
}
$input['pic'] = 1;
}
unset($input['img_url']);
if (isset($input['vid'])) {
if (isset($input['vid_url'])) {
unset($input['vid']);
if (strpos($input['vid_url'], 'youtube') > 0 || strpos($input['vid_url'], 'youtu.be') > 0) {
$video_id = Youtubehelper::extractUTubeVidId($input['vid_url']);
if (isset($video_id[1])) {
$img_url = 'http://img.youtube.com/vi/' . $video_id . '/0.jpg';
$input['pic_url'] = ImageHandler::uploadImage($img_url, 'images', true, Helper::slugify($input['title']), 'url');
} else {
unset($input['vid_url']);
}
$input['vid'] = 1;
} elseif (strpos($input['vid_url'], 'vimeo') > 0) {
$vimeo_id = (int) substr(parse_url($input['vid_url'], PHP_URL_PATH), 1);
$link = unserialize(file_get_contents("http://vimeo.com/api/v2/video/{$vimeo_id}.php"));
$image = $link[0]['thumbnail_large'];
$input['pic_url'] = ImageHandler::uploadImage($image, 'images', Helper::slugify($input['title']), 'url');
$input['vid'] = 1;
} elseif (strpos($input['vid_url'], 'vine') > 0) {
$video_id = explode('/v/', $input['vid_url']);
$video_id = str_replace('/embed', '', $video_id[1]);
$video_id = str_replace('/', '', $video_id);
if (isset($video_id)) {
ini_set('default_socket_timeout', 120);
$vine = file_get_contents("http://vine.co/v/{$video_id}");
preg_match('/property="og:image" content="(.*?)"/', $vine, $matches);
$image = $matches[1] ? $matches[1] : '';
$input['pic_url'] = ImageHandler::uploadImage($image, 'images', Helper::slugify($input['title']), 'url');
} else {
unset($input['vid_url']);
}
$input['vid'] = 1;
}
}
}
$this->add_daily_media_points();
$setting = Setting::first();
if (!$setting->auto_approve_posts) {
$input['active'] = 0;
}
if (isset($input['nsfw'])) {
$input['nsfw'] = 1;
} else {
$input['nsfw'] = 0;
}
$input['title'] = htmlspecialchars(stripslashes($input['title']));
$input['slug'] = Helper::slugify($input['title']);
if (isset($input['description'])) {
$input['description'] = htmlspecialchars(stripslashes($input['description']));
}
$slugexist = Media::where('slug', '=', $input['slug'])->first();
$increment = 1;
while (isset($slugexist->id)) {
$input['slug'] = $input['slug'] . '-' . $increment;
$slugexist = Media::where('slug', '=', $input['slug'])->first();
$increment += 1;
}
$new_media = $this->media->create($input);
return Redirect::to('media' . '/' . $new_media->slug)->with(array('note' => Lang::get('lang.upload_success'), 'note_type' => 'success'));
}
return Redirect::to('/upload')->with(array('note' => Lang::get('lang.error_uploading'), 'note_type' => 'error'));
} else {
return Redirect::to('/')->with(array('note' => Lang::get('lang.login_to_upload'), 'note_type' => 'error'));
}
}
示例8: update
/**
* Update the specified resource in storage.
*
* @param int $id
* @return Response
*/
public function update()
{
$input = Input::all();
$id = $input['id'];
$video = Video::findOrFail($id);
$validator = Validator::make($data = $input, Video::$rules);
if ($validator->fails()) {
return Redirect::back()->withErrors($validator)->withInput();
}
$tags = $data['tags'];
unset($data['tags']);
$this->addUpdateVideoTags($video, $tags);
if (isset($data['duration'])) {
//$str_time = $data
$str_time = preg_replace("/^([\\d]{1,2})\\:([\\d]{2})\$/", "00:\$1:\$2", $data['duration']);
sscanf($str_time, "%d:%d:%d", $hours, $minutes, $seconds);
$time_seconds = $hours * 3600 + $minutes * 60 + $seconds;
$data['duration'] = $time_seconds;
}
if (empty($data['image'])) {
unset($data['image']);
} else {
$data['image'] = ImageHandler::uploadImage($data['image'], 'images');
}
if (empty($data['active'])) {
$data['active'] = 0;
}
if (empty($data['featured'])) {
$data['featured'] = 0;
}
$video->update($data);
return Redirect::to('admin/videos/edit' . '/' . $id)->with(array('note' => 'Successfully Updated Video!', 'note_type' => 'success'));
}