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


PHP request::file方法代码示例

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


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

示例1: update

 public function update($id, request $request)
 {
     $frames = Frames::find($id);
     $image = $frames->image;
     $file = $request->file('image');
     if (!empty($file)) {
         $destinationPath = 'uploads/frames';
         // upload path
         $fileName = $request->file('image')->getClientOriginalName();
         // renameing image
         $request->file('image')->move($destinationPath, $fileName);
         // uploading file to given path
     } else {
         $fileName = $image;
     }
     $requests = array('name' => $request->get('name'), 'description' => $request->get('description'), 'image_layout' => $request->file('image_layout'), 'image_background' => $request->file('image_background'), 'image_foreground' => $request->file('image_foreground'), 'image_preview' => $request->file('image_preview'));
     $files = array('image_layout' => $request->file('image_layout'), 'image_background' => $request->file('image_background'), 'image_foreground' => $request->file('image_foreground'), 'image_preview' => $request->file('image_preview'));
     $rules = array('name' => 'required');
     $validator = Validator::make($requests, $rules);
     if ($validator->fails()) {
         // send back to the page with the input data and errors
         return Redirect::to('frame')->withInput()->withErrors($validator);
     } else {
         $filenames = array('image_layout' => $frames->image_layout, 'image_background' => $frames->image_background, 'image_foreground' => $frames->image_foreground, 'image_preview' => $frames->image_preview);
         foreach ($files as $fieldname => $file) {
             if (!empty($file)) {
                 // checking file is valid.
                 if ($file->isValid()) {
                     $destinationPath = 'uploads/frames';
                     // upload path
                     $extension = $file->getClientOriginalExtension();
                     // getting image extension
                     $fileName = rand(11111, 99999) . '.' . $extension;
                     // renameing image
                     //$fileName = $request->file('image')->getClientOriginalName(); // renameing image
                     $file->move($destinationPath, $fileName);
                     // uploading file to given path
                     $filenames[$fieldname] = $fileName;
                 } else {
                     // sending back with error message.
                     Session::flash('error', 'uploaded file is not valid');
                     return Redirect::to('frame');
                 }
             }
         }
         $frames->name = $request->input('name');
         $frames->description = $request->input('description');
         $frames->image_layout = $filenames['image_layout'];
         $frames->image_background = $filenames['image_background'];
         $frames->image_foreground = $filenames['image_foreground'];
         $frames->image_preview = $filenames['image_preview'];
         $frames->save();
         return redirect()->intended('frames');
     }
 }
开发者ID:abangrephol,项目名称:hairstyle-server,代码行数:55,代码来源:FramesController.php

示例2: upload

 public function upload(request $request)
 {
     // getting all of the post data
     $file = $request->file('file');
     // setting up rules
     // $rules = array('image' => 'required',); //mimes:jpeg,bmp,png and for max size max:10000
     // doing the validation, passing post data, rules and the messages
     // $validator = Validator::make($file, $rules);
     //if ($validator->fails()) {
     // send back to the page with the input data and errors
     // return Redirect::to('upload')->withInput()->withErrors($validator);
     //}
     //else {
     // checking file is valid.
     if ($file->isValid()) {
         $destinationPath = 'assets/img/spelers';
         // upload path
         $extension = $file->getClientOriginalExtension();
         // getting image extension
         $fileName = $file->getClientOriginalName();
         //.'.'.$extension ; //rand(11111,99999).'.'.$extension; // renameing image
         $file->move($destinationPath, $fileName);
         // uploading file to given path
         // sending back with message
         //Session::flash('success', 'Upload successfully');
         //return Redirect::to('upload');
     }
     /*else {
         // sending back with error message.
         Session::flash('error', 'uploaded file is not valid');
         return Redirect::to('upload');
       }*/
     //  }
 }
开发者ID:KOVV,项目名称:datavolley,代码行数:34,代码来源:HomeController.php

示例3: update

 public function update($id, request $request)
 {
     $frames = Frames::find($id);
     $image = $frames->image;
     $file = $request->file('image');
     if (!empty($file)) {
         $destinationPath = 'uploads/frames';
         // upload path
         $fileName = $request->file('image')->getClientOriginalName();
         // renameing image
         $request->file('image')->move($destinationPath, $fileName);
         // uploading file to given path
     } else {
         $fileName = $image;
     }
     $frames->name = $request->input('name');
     $frames->description = $request->input('description');
     $frames->image = $fileName;
     $frames->save();
     return redirect()->intended('frames');
 }
开发者ID:jojoalmost,项目名称:hairstyle-server,代码行数:21,代码来源:FramesController.php

示例4: fileUploads

 /**
  * file upload for photo albums or any possible model
  * if model is Album and the id is 'new', the user can create
  *
  * if any other model, the user has to be authorized
  *
  * @param $model
  * @param $model_id
  * @param $id
  *
  * @return string
  */
 public function fileUploads($model, $model_id, $id)
 {
     Helper::allow('album-new');
     $this->photos = new Photo();
     $this->_authorize($model, $model_id, $id);
     $models = str_plural($model);
     $files = array('files' => Input::file('files'));
     $rules = ['files.*.*' => 'required|mimes:png,jpeg,jpg,gif|max:8000'];
     $validation = Validator::make(['files' => $this->request->file('files')], $rules);
     $json = [];
     foreach ($files['files'] as $file) {
         $fileName = str_replace(' ', '-', strtolower($file->getClientOriginalName()));
         $json = ['name' => $fileName, 'size' => $file->getClientSize()];
         if (count($validation->errors()) > 0) {
             $json["error"] = $validation->errors()->first();
         }
         $ids = $this->album->id . '_' . Auth::id() . '_';
         $imgTitle = $ids . time() . '_' . $fileName;
         $imagePath = storage_path() . '/app/public/' . $models . '/';
         $json['name'] = $imgTitle;
         //Input::file('image')->move($imagePath, $imgTitle);
         $upload_success = Image::make($file)->resize(800, null, function ($constraint) {
             $constraint->aspectRatio();
             $constraint->upsize();
         })->save($imagePath . $imgTitle);
         if ($upload_success) {
             $this->photos->title = $this->photos->location = $imgTitle;
             $this->album->photos()->save($this->photos);
             //DB::table('albums')->where('id', $this->album->id)->update($this->album->toArray());
             $json += ['url' => '/img/cache/wm-rt-large/' . $imgTitle, 'size' => Storage::size('/public/' . $models . '/' . $imgTitle), 'deleteUrl' => '/img/delete/sites/' . $imgTitle, 'deleteType' => 'GET'];
         } else {
             $json["error"] = "Something went wrong.";
         }
     }
     return response()->json(['files' => [$json], 'album_id' => $this->album->id, 'session' => session('album_id')]);
 }
开发者ID:Dimimo,项目名称:Booklet,代码行数:48,代码来源:ImagesController.php

示例5: updateStore

 public function updateStore(request $request)
 {
     $validator = Validator::make($request->all(), ['store_id' => 'required', 'store_name' => 'required|max:255', 'landline' => 'required', 'cost_two' => 'required', 'veg' => 'required', 'status' => 'required', 'street' => 'required|max:200', 'area_id' => 'required', 'city_id' => 'required', 'state_id' => 'required', 'country_id' => 'required', 'pincode' => 'required', 'latitude' => 'required', 'longitude' => 'required']);
     $input = $request->only('store_id');
     if ($validator->fails()) {
         return redirect('admin/store/' . $input["store_id"] . '/edit')->withErrors($validator);
     }
     $store = MerchantStore::find($input['store_id']);
     foreach ($request->only('store_name', 'cost_two', 'veg', 'landline', 'status') as $key => $value) {
         $store->{$key} = $value;
     }
     if ($request->hasFile('logo')) {
         $image = $request->file('logo');
         $imageName = strtotime(Carbon::now()) . md5($input['store_id']) . '.' . $image->getClientOriginalExtension();
         $path = public_path('assets/img/stores/' . $imageName);
         Image::make($image->getRealPath())->resize(280, null, function ($constraint) {
             $constraint->aspectRatio();
         })->save($path);
         $store->logoUrl = $imageName;
     }
     $store->save();
     $store->tags()->detach();
     $tags = $request->only('tags');
     $tagStore = explode(',', $tags['tags']);
     $store->tags()->attach($tagStore);
     $matchThese = ['store_id' => $input['store_id']];
     $address = MerchantStoreAddress::where($matchThese)->first();
     foreach ($request->only('street', 'area_id', 'city_id', 'state_id', 'country_id', 'pincode', 'latitude', 'longitude') as $key => $value) {
         $address->{$key} = $value;
     }
     $address->save();
     return redirect('admin/store/' . $input['store_id']);
 }
开发者ID:abhilash698,项目名称:kachingApp,代码行数:33,代码来源:AdminController.php

示例6: editProfile

 public function editProfile(request $request)
 {
     $rules = array('email' => 'unique:users');
     $validator = $this->customValidator($request->all(), $rules, array());
     if ($validator->fails()) {
         return response()->json(['response_code' => 'ERR_EAE', 'message' => 'Email Already Exists'], 409);
     }
     $user_id = Auth::user()->id;
     $user = User::find($user_id);
     foreach ($request->only('name', 'email') as $key => $value) {
         $user->{$key} = $value;
     }
     if ($request->hasFile('profileImg')) {
         $image = $request->file('profileImg');
         $imageName = strtotime(Carbon::now()) . md5($user_id) . '.' . $image->getClientOriginalExtension();
         $path = public_path('assets/img/users/' . $imageName);
         Image::make($image->getRealPath())->resize(280, 240)->save($path);
         $user->profileImg = $imageName;
     }
     $user->save();
     return response()->json(['response_code' => 'RES_UU', 'messages' => 'User Upadated', 'data' => $user]);
 }
开发者ID:abhilash698,项目名称:kachingApp,代码行数:22,代码来源:CustomerService.php

示例7: editStore

 public function editStore(request $request)
 {
     $store_id = Auth::user()->stores->id;
     $store = MerchantStore::find($store_id);
     foreach ($request->only('store_name', 'cost_two', 'status', 'landline', 'veg', 'description') as $key => $value) {
         $store->{$key} = $value;
     }
     if ($request->hasFile('logo')) {
         $image = $request->file('logo');
         $imageName = strtotime(Carbon::now()) . md5($store_id) . '.' . $image->getClientOriginalExtension();
         $path = public_path('assets/img/stores/' . $imageName);
         Image::make($image->getRealPath())->resize(280, null, function ($constraint) {
             $constraint->aspectRatio();
         })->save($path);
         $store->logoUrl = $imageName;
     }
     $store->save();
     $store->tags()->detach();
     $tags = $request->only('tags');
     $tagStore = explode(',', $tags['tags']);
     $store->tags()->attach($tagStore);
     $matchThese = ['store_id' => $store_id];
     $address = MerchantStoreAddress::where($matchThese)->first();
     foreach ($request->only('street', 'area_id', 'city_id', 'state_id', 'country_id', 'pincode', 'latitude', 'longitude') as $key => $value) {
         $address->{$key} = $value;
     }
     $address->save();
     $output = ['store' => $store, 'address' => $address];
     return response()->json(['response_code' => 'RES_SU', 'messages' => 'Store Upadated', 'data' => $output]);
 }
开发者ID:abhilash698,项目名称:kachingApp,代码行数:30,代码来源:MerchantServiceV2.php

示例8: updateStore

 public function updateStore(request $request)
 {
     $validator = Validator::make($request->all(), ['store_id' => 'required', 'name' => 'required|max:255', 'address' => 'required|min:10', 'code' => 'required', 'cost' => 'required', 'timer' => 'required|max:200', 'is_active' => 'required']);
     $input = $request->only('store_id');
     $inputVal = $request->only('name', 'code');
     if ($validator->fails()) {
         return redirect('admin/store/' . $input["store_id"] . '/edit')->withErrors($validator);
     }
     $store = Store::find($input['store_id']);
     if ($inputVal['name'] != $store->name) {
         $validator = Validator::make($request->all(), ['name' => 'unique:stores']);
         if ($validator->fails()) {
             return redirect('admin/store/' . $input["store_id"] . '/edit')->withErrors($validator);
         }
     }
     if ($inputVal['code'] != $store->code) {
         $validator = Validator::make($request->all(), ['code' => 'unique:stores']);
         if ($validator->fails()) {
             return redirect('admin/store/' . $input["store_id"] . '/edit')->withErrors($validator);
         }
     }
     foreach ($request->only('name', 'address', 'code', 'cost', 'timer', 'is_active') as $key => $value) {
         $store->{$key} = $value;
     }
     if ($request->hasFile('offer_image')) {
         $image = $request->file('offer_image');
         $imageName = strtotime(Carbon::now()) . md5($input['store_id']) . '.' . $image->getClientOriginalExtension();
         $path = public_path('assets/img/stores/' . $imageName);
         Image::make($image->getRealPath())->resize(280, 240)->save($path);
         $store->offer_image = $imageName;
     }
     $store->save();
     return redirect('admin/store/' . $input['store_id']);
 }
开发者ID:abhilash698,项目名称:projectc,代码行数:34,代码来源:SuperAdminController.php

示例9: editStore

 public function editStore(request $request)
 {
     $store_id = $request->only('store_id');
     if (!$this->checkUserHasStore($store_id['store_id'], false)) {
         return response()->json(['response_code' => 'ERR_UNA', 'messages' => 'User Not Authorized'], 403);
     }
     $store = MerchantStore::find($store_id['store_id']);
     foreach ($request->only('store_name', 'description', 'cost_two', 'status') as $key => $value) {
         $store->{$key} = $value;
     }
     if ($request->hasFile('logo')) {
         $image = $request->file('logo');
         $imageName = strtotime(Carbon::now()) . md5($input['store_id']) . '.' . $image->getClientOriginalExtension();
         $path = public_path('assets/img/stores/' . $imageName);
         Image::make($image->getRealPath())->resize(280, 240)->save($path);
         $store->logoUrl = $imageName;
     }
     $store->save();
     $store->tags()->detach();
     $tags = $request->only('tags');
     $tagStore = explode(',', $tags['tags']);
     $store->tags()->attach($tagStore);
     $matchThese = ['store_id' => $store_id['store_id']];
     $address = MerchantStoreAddress::where($matchThese)->first();
     foreach ($request->only('street', 'city_id', 'state_id', 'country_id', 'pincode', 'latitude', 'longitude') as $key => $value) {
         $address->{$key} = $value;
     }
     $address->save();
     $output = ['store' => $store, 'address' => $address];
     return response()->json(['response_code' => 'RES_SU', 'messages' => 'Store Upadated', 'data' => $output]);
 }
开发者ID:abhilash698,项目名称:projectK,代码行数:31,代码来源:MerchantService.php

示例10: postApplyForTravel

 public function postApplyForTravel(request $request)
 {
     $travelRequested = "";
     if (isset($_POST['OfficialBusinesswithAirfare']) == true && $_POST['OfficialBusinesswithAirfare'] == true) {
         $travelRequested .= "Official Business with Airfare,";
     }
     if (isset($_POST['officialTime']) == true && $_POST['officialTime'] == true) {
         $travelRequested .= "Official time,";
     }
     if ($travelRequested != "") {
         $travelRequested = rtrim($travelRequested, ",");
     }
     $applicationEntitlements = "";
     if (isset($_POST['entitlementrequestedInternationalAirfare'])) {
         $applicationEntitlements .= "International airfare (economy);";
     }
     if (isset($_POST['entitlementrequestedTravelAllowance'])) {
         $applicationEntitlements .= 'Travel allowance;';
     }
     if (isset($_POST['entitlementrequestedRegistrationParticipationFee'])) {
         $applicationEntitlements .= 'Registration fee / participation fee;';
     }
     if (isset($_POST['entitlementrequestedOthers'])) {
         $applicationEntitlements .= "others;";
     }
     $travelType = "";
     if (isset($_POST['officialTime'])) {
         $travelType .= 'OTO;';
     }
     if (isset($_POST['OfficialBusinesswithAirfare'])) {
         $travelType .= 'OB;';
     }
     if (isset($_POST['OfficialLeaveOfAbsence'])) {
         $travelType .= 'OLA;';
     }
     if (isset($_POST['travelType'])) {
         $travelType = $_POST['travelType'];
     }
     $administrativeRequirement = "";
     if (isset($_POST['administrativeRequirements'])) {
         $administrativeRequirement = $_POST['administrativeRequirements'];
     }
     $municipality = isset($_POST['municipality']) ? $_POST['municipality'] : "";
     $insert = ['applicationstatus_id' => 1, 'remarks' => "", 'region' => trim(Auth::user()->region), 'province' => trim($_POST['selectprovince']), 'municipality' => $municipality, 'firstname' => trim($_POST['firstname']), 'lastname' => trim($_POST['lastname']), 'middlename' => trim($_POST['middlename']), 'sex' => trim($_POST['sex']), 'suffix' => trim($_POST['suffix']), 'birthdate' => $_POST['birthdate'], 'positionType' => $_POST['positionType'], 'position' => $_POST['positionType'] == "NON ELECTIVE" ? $_POST['nonelectiveposition'] : $_POST['position'], 'picture' => 'pictures/' . $_FILES['picture']['name'], 'mobile' => $_POST['mobilenumber'], 'travelType' => $travelType, 'groupDelegation' => $_POST['groupDelegation'], 'benefits' => $_POST['benefits'], 'created_at' => date("Y-m-d H:i:s"), 'email' => $_POST['email'], 'encodedBy' => Auth::user()->lastname . ", " . Auth::user()->firstname . ", " . Auth::user()->middlename];
     //todo: add some back-end validation
     if (isset($_POST['apply'])) {
         $travel = travelApplication::create($insert);
         $this->travelApplication_id = $travel->id;
         if ($travel->id) {
             $travelApplication_id = $travel->id;
             $this->travelApplication_id = $travel->id;
             $flights = [];
             foreach ($_POST['travel_flight'] as $travel_i) {
                 array_push($flights, ["country" => $travel_i["country"], "datefrom" => $travel_i["datefrom"], "dateto" => $travel_i["dateto"], "benefits" => $travel_i["benefits"], "groupdelegation" => $travel_i["groupdelegation"], "natureoftravelrequested" => $travel_i["natureoftravelrequested"], "traveltype" => $travel_i["traveltype"], "entitlementsrequested" => $travel_i["entitlementsrequested"], "undertravelallowance" => $travel_i["undertravelallowance"]]);
             }
             foreach ($flights as $flight) {
                 $travel_insert = ["country" => $flight["country"], "datefrom" => $flight["datefrom"], "travelapplication_id" => $travel->id, "dateto" => $flight["dateto"], "benefits" => $flight["benefits"], "groupdelegation" => $flight["groupdelegation"], "natureoftravelrequested" => $flight["natureoftravelrequested"], "traveltype" => $flight["traveltype"], "entitlementsrequested" => $flight["entitlementsrequested"], "undertravelallowance" => $flight["undertravelallowance"]];
                 $travel_flight_insert = travelflight::create($travel_insert);
             }
             //upload picture
             if ($request->hasFile('picture')) {
                 //
                 $request->file('picture')->move('pictures/', $request->file('picture')->getClientOriginalName());
             } else {
                 die("error uploading picture");
                 exit;
             }
             //upload updated pic
             if ($request->hasFile('updatedPicture')) {
                 //upload updated picture
                 $request->file('updatedPicture')->move('documents/', $request->file('updatedPicture')->getClientOriginalName());
                 $attachedUpdatedPicture = new attachedDocuments();
                 $attachedUpdatedPicture->name = $request->file('updatedPicture')->getClientOriginalName();
                 $attachedUpdatedPicture->location = 'documents/' . $request->file('updatedPicture')->getClientOriginalName();
                 $attachedUpdatedPicture->travelApplication_id = $this->travelApplication_id;
                 $attachedUpdatedPicture->created_at = date("Y-m-d");
                 $attachedUpdatedPicture->categories = "updated picture";
                 $attachedUpdatedPicture->save();
             }
             //upload docs
             if ($request->hasFile('documents')) {
                 //
                 for ($i = 0; $i <= count($request->file('documents')) - 1; $i++) {
                     if ($request->file('documents')[$i]) {
                         $request->file('documents')[$i]->move('documents/', $request->file('documents')[$i]->getClientOriginalName());
                         $attachedDocument = new attachedDocuments();
                         $attachedDocument->name = $request->file('documents')[$i]->getClientOriginalName();
                         $attachedDocument->location = 'documents/' . $request->file('documents')[$i]->getClientOriginalName();
                         $attachedDocument->travelApplication_id = $this->travelApplication_id;
                         $attachedDocument->created_at = date("Y-m-d");
                         $attachedDocument->remarks = $request->documentremarks[$i];
                         $attachedDocument->save();
                     }
                 }
             } else {
                 // die("error uploading document(s)");
                 // exit();
             }
             //upload docs
             return redirect('home');
//.........这里部分代码省略.........
开发者ID:abrenicamarkjoshua,项目名称:TravelDilg,代码行数:101,代码来源:HomeController.php


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