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


PHP File::uploadFile方法代码示例

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


在下文中一共展示了File::uploadFile方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Motion $motion, Request $request)
 {
     if (!Auth::user()->can('create-motions')) {
         abort(401, 'You do not have permission to create a motion');
     }
     $file = new File();
     $file->uploadFile('motion_files', 'file', $request);
     if (!$file->save()) {
         abort(403, $file->errors);
     }
     $motionFile = new MotionFile();
     $motionFile->motion_id = $motion->id;
     $motionFile->file_id = $file->id;
     if (!$motionFile->save()) {
         abort(403, $motionFile->errors);
     }
     return $motionFile;
 }
开发者ID:dwoodard,项目名称:IserveU,代码行数:23,代码来源:MotionFileController.php

示例2: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     $validator = Validator::make(array('image' => Input::file('image')), array('image' => 'image'));
     if ($validator->fails()) {
         abort(403, 'file is not an image');
     }
     $file = new File();
     $file->uploadFile('background_images', 'background_images', $request);
     if (!$file->save()) {
         abort(403, $file->errors);
     }
     $backgroundImage = (new BackgroundImage())->secureFill($request->all());
     $backgroundImage->user_id = Auth::user()->id;
     $backgroundImage->file_id = $file->id;
     if (!$backgroundImage->save()) {
         abort(403, $backgroundImage->errors);
     }
     return $backgroundImage;
 }
开发者ID:dwoodard,项目名称:IserveU,代码行数:24,代码来源:BackgroundImageController.php

示例3: update

 /**
  * Can't update most of the fields once they have been verified, only email/password/pubilc.
  *
  * @param  User   		$user
  * @return Response
  */
 public function update(User $user, Request $request)
 {
     if ($user->id != Auth::user()->id && !Auth::user()->can('administrate-users')) {
         abort(401, 'You do not have permission to edit this user');
     }
     //If the user has the authentication level, they can change some things
     $user->secureFill($request->except('token'));
     if (!$user->save()) {
         //Validation failed
         abort(400, $user->errors);
     }
     if ($request->file('government_identification')) {
         $file = new File();
         $file->uploadFile('government_identification', 'government_identification', $request);
         if (!$file->save()) {
             abort(403, $file->errors);
         }
         $user->government_identification_id = $file->id;
     }
     if ($request->file('avatar')) {
         $file = new File();
         $file->uploadFile('avatars', 'avatar', $request);
         if (!$file->save()) {
             abort(403, $file->errors);
         }
         $user->government_identification_id = $file->id;
     }
     $user->save();
     return $user;
 }
开发者ID:vitz3,项目名称:IserveU,代码行数:36,代码来源:UserController.php


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