当前位置: 首页>>代码示例>>PHP>>正文


PHP Binput::hasFile方法代码示例

本文整理汇总了PHP中GrahamCampbell\Binput\Facades\Binput::hasFile方法的典型用法代码示例。如果您正苦于以下问题:PHP Binput::hasFile方法的具体用法?PHP Binput::hasFile怎么用?PHP Binput::hasFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GrahamCampbell\Binput\Facades\Binput的用法示例。


在下文中一共展示了Binput::hasFile方法的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: postSettings

 /**
  * Updates the status page settings.
  *
  * @return \Illuminate\View\View
  */
 public function postSettings()
 {
     $setting = app(Repository::class);
     if (Binput::get('remove_banner') === '1') {
         $setting->set('app_banner', null);
     }
     $parameters = Binput::all();
     if (isset($parameters['header'])) {
         if ($header = Binput::get('header', null, false, false)) {
             $setting->set('header', $header);
         } else {
             $setting->delete('header');
         }
     }
     if (isset($parameters['footer'])) {
         if ($footer = Binput::get('footer', null, false, false)) {
             $setting->set('footer', $footer);
         } else {
             $setting->delete('footer');
         }
     }
     if (Binput::hasFile('app_banner')) {
         $this->handleUpdateBanner($setting);
     }
     $excludedParams = ['_token', 'app_banner', 'remove_banner', 'header', 'footer'];
     try {
         foreach (Binput::except($excludedParams) as $settingName => $settingValue) {
             if ($settingName === 'app_analytics_pi_url') {
                 $settingValue = rtrim($settingValue, '/');
             }
             $setting->set($settingName, $settingValue);
         }
     } catch (Exception $e) {
         return Redirect::back()->withErrors(trans('dashboard.settings.edit.failure'));
     }
     if (Binput::has('app_locale')) {
         Lang::setLocale(Binput::get('app_locale'));
     }
     return Redirect::back()->withSuccess(trans('dashboard.settings.edit.success'));
 }
开发者ID:aksalj,项目名称:Cachet,代码行数:45,代码来源:SettingsController.php


注:本文中的GrahamCampbell\Binput\Facades\Binput::hasFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。