當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Binput::file方法代碼示例

本文整理匯總了PHP中GrahamCampbell\Binput\Facades\Binput::file方法的典型用法代碼示例。如果您正苦於以下問題:PHP Binput::file方法的具體用法?PHP Binput::file怎麽用?PHP Binput::file使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在GrahamCampbell\Binput\Facades\Binput的用法示例。


在下文中一共展示了Binput::file方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: postSettings

 /**
  * Updates the status page settings.
  *
  * @return \Illuminate\View\View
  */
 public function postSettings()
 {
     if (Binput::get('remove_banner') == "1") {
         $setting = Setting::where('name', 'app_banner');
         $setting->delete();
     }
     if (Binput::hasFile('app_banner')) {
         $file = Binput::file('app_banner');
         // Image Validation.
         // Image size in bytes.
         $maxSize = $file->getMaxFilesize();
         if ($file->getSize() > $maxSize) {
             return Redirect::back()->withErrorMessage("You need to upload an image that is less than {$maxSize}.");
         }
         if (!$file->isValid() || $file->getError()) {
             return Redirect::back()->withErrorMessage($file->getErrorMessage());
         }
         if (strpos($file->getMimeType(), 'image/') !== 0) {
             return Redirect::back()->withErrorMessage('Only images may be uploaded.');
         }
         // Store the banner.
         Setting::firstOrCreate(['name' => 'app_banner'])->update(['value' => base64_encode(file_get_contents($file->getRealPath()))]);
         // Store the banner type
         Setting::firstOrCreate(['name' => 'app_banner_type'])->update(['value' => $file->getMimeType()]);
     }
     try {
         foreach (Binput::except(['app_banner', 'remove_banner']) as $settingName => $settingValue) {
             Setting::firstOrCreate(['name' => $settingName])->update(['value' => $settingValue]);
         }
     } catch (Exception $e) {
         return Redirect::back()->withSaved(false);
     }
     return Redirect::back()->withSaved(true);
 }
開發者ID:baa-archieve,項目名稱:Cachet,代碼行數:39,代碼來源:DashSettingsController.php

示例2: postSettings

 /**
  * Updates the status page settings.
  *
  * @return \Illuminate\View\View
  */
 public function postSettings()
 {
     if (Binput::get('remove_banner') === '1') {
         $setting = Setting::where('name', 'app_banner');
         $setting->delete();
     }
     if (Binput::hasFile('app_banner')) {
         $file = Binput::file('app_banner');
         // Image Validation.
         // Image size in bytes.
         $maxSize = $file->getMaxFilesize();
         if ($file->getSize() > $maxSize) {
             return Redirect::route('dashboard.settings.setup')->withErrors(trans('dashboard.settings.app-setup.too-big', ['size' => $maxSize]));
         }
         if (!$file->isValid() || $file->getError()) {
             return Redirect::route('dashboard.settings.setup')->withErrors($file->getErrorMessage());
         }
         if (strpos($file->getMimeType(), 'image/') !== 0) {
             return Redirect::route('dashboard.settings.setup')->withErrors(trans('dashboard.settings.app-setup.images-only'));
         }
         // Store the banner.
         Setting::firstOrCreate(['name' => 'app_banner'])->update(['value' => base64_encode(file_get_contents($file->getRealPath()))]);
         // Store the banner type
         Setting::firstOrCreate(['name' => 'app_banner_type'])->update(['value' => $file->getMimeType()]);
     }
     try {
         foreach (Binput::except(['app_banner', 'remove_banner']) as $settingName => $settingValue) {
             if ($settingName === 'app_analytics_pi_url') {
                 $settingValue = rtrim($settingValue, '/');
             }
             Setting::firstOrCreate(['name' => $settingName])->update(['value' => $settingValue]);
         }
     } catch (Exception $e) {
         return Redirect::route('dashboard.settings.setup')->withErrors(trans('dashboard.settings.edit.failure'));
     }
     if (Binput::has('app_locale')) {
         Lang::setLocale(Binput::get('app_locale'));
     }
     return Redirect::route('dashboard.settings.setup')->withSuccess(trans('dashboard.settings.edit.success'));
 }
開發者ID:reviforks,項目名稱:Cachet,代碼行數:45,代碼來源:SettingsController.php

示例3: postSettings

 /**
  * Updates the status page settings.
  *
  * @return \Illuminate\View\View
  */
 public function postSettings()
 {
     $redirectUrl = Session::get('redirect_to', route('dashboard.settings.setup'));
     $setting = app('setting');
     if (Binput::get('remove_banner') === '1') {
         $setting->set('app_banner', null);
     }
     if (Binput::hasFile('app_banner')) {
         $file = Binput::file('app_banner');
         // Image Validation.
         // Image size in bytes.
         $maxSize = $file->getMaxFilesize();
         if ($file->getSize() > $maxSize) {
             return Redirect::to($redirectUrl)->withErrors(trans('dashboard.settings.app-setup.too-big', ['size' => $maxSize]));
         }
         if (!$file->isValid() || $file->getError()) {
             return Redirect::to($redirectUrl)->withErrors($file->getErrorMessage());
         }
         if (!starts_with($file->getMimeType(), 'image/')) {
             return Redirect::to($redirectUrl)->withErrors(trans('dashboard.settings.app-setup.images-only'));
         }
         // Store the banner.
         $setting->set('app_banner', base64_encode(file_get_contents($file->getRealPath())));
         // Store the banner type.
         $setting->set('app_banner_type', $file->getMimeType());
     }
     try {
         foreach (Binput::except(['app_banner', 'remove_banner', '_token']) as $settingName => $settingValue) {
             if ($settingName === 'app_analytics_pi_url') {
                 $settingValue = rtrim($settingValue, '/');
             }
             $setting->set($settingName, $settingValue);
         }
     } catch (Exception $e) {
         return Redirect::to($redirectUrl)->withErrors(trans('dashboard.settings.edit.failure'));
     }
     if (Binput::has('app_locale')) {
         Lang::setLocale(Binput::get('app_locale'));
     }
     return Redirect::to($redirectUrl)->withSuccess(trans('dashboard.settings.edit.success'));
 }
開發者ID:uwm-appbrewery,項目名稱:Cachet,代碼行數:46,代碼來源:SettingsController.php

示例4: handleUpdateBanner

 /**
  * Handle updating of the banner image.
  *
  * @param \CachetHQ\Cachet\Settings\Repository $setting
  *
  * @return void
  */
 protected function handleUpdateBanner(Repository $setting)
 {
     $file = Binput::file('app_banner');
     // Image Validation.
     // Image size in bytes.
     $maxSize = $file->getMaxFilesize();
     if ($file->getSize() > $maxSize) {
         return Redirect::to($redirectUrl)->withErrors(trans('dashboard.settings.app-setup.too-big', ['size' => $maxSize]));
     }
     if (!$file->isValid() || $file->getError()) {
         return Redirect::to($redirectUrl)->withErrors($file->getErrorMessage());
     }
     if (!Str::startsWith($file->getMimeType(), 'image/')) {
         return Redirect::to($redirectUrl)->withErrors(trans('dashboard.settings.app-setup.images-only'));
     }
     // Store the banner.
     $setting->set('app_banner', base64_encode(file_get_contents($file->getRealPath())));
     // Store the banner type.
     $setting->set('app_banner_type', $file->getMimeType());
 }
開發者ID:aksalj,項目名稱:Cachet,代碼行數:27,代碼來源:SettingsController.php


注:本文中的GrahamCampbell\Binput\Facades\Binput::file方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。