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


PHP Request::hasFile方法代码示例

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


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

示例1: editUser

 public function editUser($id, Request $request)
 {
     $user = User::find($id);
     if ($request->has('first')) {
         $user->first = $request->input('first');
     }
     if ($request->has('last')) {
         $user->last = $request->input('last');
     }
     if ($request->has('email')) {
         $user->email = $request->input('email');
     }
     if ($request->has('phone')) {
         $user->phone = $request->input('phone');
     }
     if ($request->hasFile('resume')) {
         $request->file('resume')->move(public_path('resumes'), $user->first . '-' . $user->last . '-' . $user->id . '.jpg');
         $user->resume = '/resumes/' . $user->first . '-' . $user->last . '-' . $user->id . '.jpg';
     }
     if ($request->hasFile('headshot')) {
         $request->file('headshot')->move(public_path('headshots'), $user->first . '-' . $user->last . '-' . $user->id . '.jpg');
         $user->headshot = '/headshots/' . $user->first . '-' . $user->last . '-' . $user->id . '.jpg';
     }
     if ($request->has('user_type')) {
         $user->user_type = $request->input('user_type');
     }
     $request->session()->flash('success', 'User Updated!');
     $user->save();
     return view('admin.user-edit', ['user' => $user]);
 }
开发者ID:sipplified,项目名称:AuditionAnswer,代码行数:30,代码来源:ManageController.php

示例2: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     $dmr = $request->all();
     if ($request->hasFile('uploaded_report')) {
         $reportPath = 'discrepant_material/reports/' . date("Y", time()) . '/';
         // Set the filename to the workorder_customer_process_time()
         $reportFilename = $request->workorder . '_' . $request->customer . '_' . $request->process . '_' . time() . '.' . $request->file('uploaded_report')->getClientOriginalExtension();
         // add three attributes to the array
         $dmr['report_path'] = $reportPath;
         $dmr['report_filename'] = $reportFilename;
         $dmr['report_mime'] = $request->file('uploaded_report')->getClientMimeType();
         // move the file to the proper location with its new name
         $request->file('uploaded_report')->move($reportPath, $reportFilename);
     }
     if ($request->hasFile('uploaded_image')) {
         $imagePath = 'discrepant_material/images/' . date("Y", time()) . '/';
         // Set the filename to the workorder_customer_process_time()
         $imageFilename = $request->workorder . '_' . $request->customer . '_' . $request->process . '_' . time() . '.' . $request->file('uploaded_image')->getClientOriginalExtension();
         // add three attributes to the array
         $dmr['image_path'] = $imagePath;
         $dmr['image_filename'] = $imageFilename;
         $dmr['image_mime'] = $request->file('uploaded_image')->getClientMimeType();
         // move the file to the proper location with its new name
         $request->file('uploaded_image')->move($imagePath, $imageFilename);
     }
     DMR::create($dmr);
     Session::flash('flash_message', 'Discrepant Material Report added!');
     return redirect('dmrs');
 }
开发者ID:wink-,项目名称:pluto,代码行数:34,代码来源:DiscrepantMaterialReportsController.php

示例3: updateProfile

 public function updateProfile(Request $request)
 {
     $user = User::find(Auth::user()->id);
     if ($request->has('first')) {
         $user->first = $request->input('first');
     }
     if ($request->has('last')) {
         $user->last = $request->input('last');
     }
     if ($request->has('email')) {
         $user->email = $request->input('email');
     }
     if ($request->has('phone')) {
         $user->phone = $request->input('phone');
     }
     if ($request->hasFile('resume')) {
         $request->file('resume')->move(public_path('resumes'), $user->first . '_' . $user->last . '_' . $user->id . '.' . $request->file('resume')->getClientOriginalExtension());
         $user->resume = '/resumes/' . $user->first . '_' . $user->last . '_' . $user->id . '.' . $request->file('resume')->getClientOriginalExtension();
     }
     if ($request->hasFile('headshot')) {
         $request->file('headshot')->move(public_path('headshots'), $user->first . '_' . $user->last . '_' . $user->id . '.' . $request->file('headshot')->getClientOriginalExtension());
         $user->headshot = '/headshots/' . $user->first . '_' . $user->last . '_' . $user->id . '.' . $request->file('headshot')->getClientOriginalExtension();
     }
     $user->save();
     $request->session()->flash('success', 'Profile Updated!');
     return view('editProfile', ['user' => $user]);
 }
开发者ID:sipplified,项目名称:AuditionAnswer,代码行数:27,代码来源:HomeController.php

示例4: update

 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $validacao = Validator::make($request->all(), ['nome_site' => 'required|string', 'logo' => 'image|mimes:jpg,jpeg,png,gif', 'logo_footer' => 'image|mimes:jpg,jpeg,png,gif']);
     if ($validacao->fails()) {
         return redirect('admin/configuracoes/site')->withErrors($validacao)->withInput();
     } else {
         try {
             $config = Configuracao::find($id);
             $config->nome_site = $request->nome_site;
             if ($request->hasFile('logo')) {
                 if ($request->file('logo')->isValid()) {
                     $nomeOriginal = $request->file('logo')->getClientOriginalName();
                     $novoNome = md5(uniqid($nomeOriginal)) . '.' . $request->file('logo')->getClientOriginalExtension();
                     $request->file('logo')->move('uploads/logo', $novoNome);
                     $config->logo = $novoNome;
                 }
             }
             if ($request->hasFile('logo_footer')) {
                 if ($request->file('logo_footer')->isValid()) {
                     $nomeOriginal = $request->file('logo_footer')->getClientOriginalName();
                     $novoNome = md5(uniqid($nomeOriginal)) . '.' . $request->file('logo_footer')->getClientOriginalExtension();
                     $request->file('logo_footer')->move('uploads/logo', $novoNome);
                     $config->logo_footer = $novoNome;
                 }
             }
             $config->save();
             session()->flash('flash_message', 'Registro atualizado com sucesso!');
         } catch (\Exception $e) {
             LogR::exception($config, $e);
             session()->flash('flash_message', 'Ops!! Ocorreu algum problema!. ' . $e->getMessage());
         }
         return Redirect::back();
     }
 }
开发者ID:safaricco,项目名称:admfw,代码行数:41,代码来源:Configuracoes.php

示例5: update

 public function update(Request $request)
 {
     $user = $request->auth;
     $id = $request->route('id');
     $uniq = md5(uniqid(time(), true));
     if ($request->hasFile('image')) {
         $types = array('115x69', '285x170', '617x324');
         // Width and height for thumb and resiged
         $sizes = array(array('115', '69'), array('285', '170'), array('617', '324'));
         $targetPath = 'img/media/';
         $image = $request->file('image');
         $ext = $image->getClientOriginalExtension();
         foreach ($types as $key => $type) {
             Image::make($image)->fit($sizes[$key][0], $sizes[$key][1])->save($targetPath . $type . "/" . $uniq . '.' . $ext);
         }
     }
     $post = PostModel::findOrFail($id);
     $post->pos_name = ucfirst($request->input('pos_name'));
     $post->pos_slug = $request->input('pos_slug');
     if ($request->hasFile('image')) {
         $post->pos_image = $uniq . '.' . $ext;
     }
     $post->pos_sum = $request->input('pos_sum');
     $post->pos_desc = $request->input('pos_desc');
     $post->pos_status_cd = "ACT";
     $post->cat_id = $request->input('cat_id');
     $post->updated_by = $user->usr_id;
     if (!$post->save()) {
         return "Error";
     }
     return Redirect::route('postHome');
 }
开发者ID:sochea09,项目名称:laravel-blog,代码行数:32,代码来源:Post.php

示例6: update

 public function update(Request $request, $id)
 {
     $params = $request->all();
     $freepost = FreePost::find($id);
     if ($freepost != null) {
         if ($request->hasFile('coverImage')) {
             $file = $request->file('coverImage');
             $fileName = md5(uniqid()) . '.' . $file->getClientOriginalExtension();
             $file->move(base_path() . '/public/upload', $fileName);
             $params['cover'] = '/upload/' . $fileName;
         }
         unset($params['coverImage']);
         if ($request->hasFile('headImage')) {
             $file = $request->file('headImage');
             $fileName = md5(uniqid()) . '.' . $file->getClientOriginalExtension();
             $file->move(base_path() . '/public/upload', $fileName);
             $params['head_image'] = '/upload/' . $fileName;
         }
         unset($params['headImage']);
         unset($params['_token']);
         foreach ($params as $n => $p) {
             $freepost->{$n} = $p;
         }
         $freepost->save();
     }
     return redirect()->action('Admin\\FreePostController@show');
 }
开发者ID:Lazybin,项目名称:huisa,代码行数:27,代码来源:FreePostController.php

示例7: createJob

 public function createJob(Request $request)
 {
     $customerID = $request->input('id');
     $label = $request->input('label');
     $cost = $request->input('cost');
     $year = $request->input('year');
     $month = $request->input('month');
     $day = $request->input('day');
     $Service = $year . ',' . $month . ',' . $day;
     $description = $request->input('description');
     $jobID = DB::table('jobs')->insertGetId(['id' => $customerID, 'label' => $label, 'description' => $description, 'Service' => $Service, 'cost' => $cost]);
     $target_path = "assets/";
     $jobImage = DB::table('jobImages')->insertGetId(['jobNumber' => $jobID, 'customerID' => $customerID]);
     if ($request->hasFile('pic1')) {
         $image1 = $request->file('pic1');
         $extension1 = $image1->getClientOriginalExtension();
         $request->file('pic1')->move($target_path, $customerID . '-' . $jobID . '-' . '0.' . $extension1);
         DB::table('jobImages')->where('imageID', $jobImage)->update(['label1' => $customerID . '-' . $jobID . '-' . '0.' . $extension1]);
     }
     if ($request->hasFile('pic2')) {
         $image2 = $request->file('pic2');
         $extension2 = $image2->getClientOriginalExtension();
         $request->file('pic2')->move($target_path, $customerID . '-' . $jobID . '-' . '1.' . $extension2);
         DB::table('jobImages')->where('imageID', $jobImage)->update(['label2' => $customerID . '-' . $jobID . '-' . '1.' . $extension2]);
     }
     if ($request->hasFile('pic3')) {
         $image3 = $request->file('pic3');
         $extension3 = $image3->getClientOriginalExtension();
         $request->file('pic3')->move($target_path, $customerID . '-' . $jobID . '-' . '2.' . $extension3);
         DB::table('jobImages')->where('imageID', $jobImage)->update(['label3' => $customerID . '-' . $jobID . '-' . '2.' . $extension3]);
     }
     return redirect()->back();
 }
开发者ID:pheinrichs,项目名称:loquacious-turtle,代码行数:33,代码来源:MainController.php

示例8: postStore

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function postStore(Request $request)
 {
     $input = $request->all();
     //		return ($input['Administrative']);
     DB::beginTransaction();
     $apps = Application::create($input['REGISTRANT']);
     $input['Administrative']['registrant_id'] = $apps->id;
     $input['Technical']['registrant_id'] = $apps->id;
     if ($request->hasFile("image1")) {
         $destinationPath = 'uploads/a/';
         $fileName = time() . "-" . $request->file('image1')->getClientOriginalName();
         $request->file('image1')->move($destinationPath, $fileName);
         $input['Administrative']['image'] = $fileName;
     }
     if ($request->hasFile('image2')) {
         $destinationPath = 'uploads/t/';
         $fileName = time() . "-" . $request->file('image2')->getClientOriginalName();
         $request->file('image2')->move($destinationPath, $fileName);
         $input['Technical']['image'] = $fileName;
     }
     return 1;
     Administrative::create($input['Administrative']);
     Technical::create($input['Technical']);
     DB::commit();
     return redirect()->back()->withSuccess('Application Submitted Successfully');
 }
开发者ID:bappa2du,项目名称:laravel_admin_lte,代码行数:31,代码来源:WebController.php

示例9: postIndex

 public function postIndex(Request $request)
 {
     $user = $request->user();
     if (UserProfile::where('user_id', $user->id)->count()) {
         $profile = UserProfile::where('user_id', $user->id)->first();
         $profile_picture = $profile->profile_pic;
         $proof = $profile->photo_id_proof;
     } else {
         $profile = new UserProfile();
         $profile_picture = NULL;
         $proof = NULL;
     }
     if ($request->hasFile('profile_picture')) {
         $profile_picture = $user->id . '_' . $request->file('profile_picture')->getClientOriginalName();
         $request->file('profile_picture')->move('uploads/profile_pics/', $profile_picture);
     }
     if ($request->hasFile('proof')) {
         $proof = $user->id . '_' . $request->file('proof')->getClientOriginalName();
         $request->file('proof')->move('uploads/proof/', $proof);
     }
     $profile->user_id = $user->id;
     $profile->profile_pic = $profile_picture;
     $profile->designation = $request->designation;
     $profile->address = $request->address;
     $profile->city = $request->city;
     $profile->state = $request->state;
     $profile->country = $request->country;
     $profile->photo_id_proof = $proof;
     $profile->save();
     return redirect('profile');
 }
开发者ID:keshavkatwe,项目名称:IgnitoOpenHouse,代码行数:31,代码来源:ProfileController.php

示例10: anyUpload

 public function anyUpload(InterfaceFileStorage $userFileStorage, AmqpWrapper $amqpWrapper, Server $server, UploadEntity $uploadEntity)
 {
     /* @var \App\Components\UserFileStorage $userFileStorage */
     $responseVariables = ['uploadStatus' => false, 'storageErrors' => [], 'uploadEntities' => []];
     if ($this->request->isMethod('post') && $this->request->hasFile('file') && $this->request->file('file')->isValid()) {
         $tmpDir = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'tmp-user-files-to-storage' . DIRECTORY_SEPARATOR;
         $tmpFilePath = $tmpDir . $this->request->file('file')->getClientOriginalName();
         $this->request->file('file')->move($tmpDir, $this->request->file('file')->getClientOriginalName());
         $userFileStorage->setValidationRules($this->config->get('storage.userfile.validation'));
         $newStorageFile = $userFileStorage->addFile($tmpFilePath);
         if ($newStorageFile && !$userFileStorage->hasErrors()) {
             /* @var \SplFileInfo $newStorageFile */
             // AMQP send $newfile, to servers
             foreach ($server->all() as $server) {
                 if (count($server->configs) > 0) {
                     foreach ($server->configs as $config) {
                         // Send server and file info to upload queue task
                         $amqpWrapper->sendMessage($this->config->get('amqp.queues.uploader.upload'), json_encode(['file' => $newStorageFile->getRealPath(), 'url' => $server->scheme . '://' . $config->auth . '@' . $server->host . '/' . trim($config->path, '\\/')]));
                     }
                 } else {
                     // The server has no configuration
                     $amqpWrapper->sendMessage($this->config->get('amqp.queues.uploader.upload'), json_encode(['file' => $newStorageFile->getRealPath(), 'url' => $server->scheme . '://' . $server->host]));
                 }
             }
             $responseVariables['uploadStatus'] = true;
         } else {
             $responseVariables['storageErrors'] = $userFileStorage->getErrors();
         }
         if ($this->request->ajax()) {
             return $this->response->json($responseVariables);
         }
     }
     $responseVariables['uploadEntities'] = $uploadEntity->limit(self::UPLOAD_ENTITIES_LIMIT)->orderBy('created_at', 'DESC')->get();
     return $this->view->make('upload.index', $responseVariables);
 }
开发者ID:ysaroka,项目名称:uploader,代码行数:35,代码来源:UploadController.php

示例11: postUpload

 public function postUpload(Request $request)
 {
     $error = false;
     if ($request->hasFile('file') && $request->has('type') && $request->has('folder')) {
         $type = $request->input('type');
         $folder = $request->input('folder');
         $file = $request->file('file');
         if ($type == 'image') {
             $filesize = \FuncNode::check_var('image_size');
             $file_array = explode(',', \FuncNode::check_var('image_extension'));
             $error_size = 'La imagen debe tener un tamaño menor a ' . $filesize . ' MB.';
             $error_ext = 'Debe ingresar una imagen valida.';
         } else {
             $filesize = \FuncNode::check_var('file_size');
             $file_array = explode(',', \FuncNode::check_var('file_extension'));
             $error_size = 'El archivo debe tener un tamaño menor a ' . $filesize . ' MB.';
             $error_ext = 'Debe ingresar un archivo en un formato valido.';
         }
         $file_size = $file->getClientSize();
         $file_name = (string) $file->getClientOriginalName();
         $file_ext = (string) $file->getClientOriginalExtension();
         if ($file_size > $filesize * 1000000) {
             $error = $file_name . ': ' . $error_size;
         } else {
             if (!in_array($file_ext, $file_array)) {
                 $error = $file_name . ': ' . $error_ext;
             }
         }
     } else {
         if (!$request->hasFile('file')) {
             $error = 'Debe ingresar un archivo válido.';
         } else {
             if (!$request->has('type')) {
                 $error = 'Debe ingresar un tipo de archivo.';
             } else {
                 if (!$request->has('folder')) {
                     $error = 'Debe ingresar un folder válido.';
                 }
             }
         }
     }
     if ($error === false) {
         if ($type == 'image') {
             $new_file = Asset::upload_image($file, $folder);
             $get_file = Asset::get_image_path($folder, 'normal', $new_file);
             $get_thumb = Asset::get_image_path($folder, 'mini', $new_file);
         } else {
             $new_file = Asset::upload_file($file, $folder);
             $get_file = Asset::get_file($folder, $new_file);
             $get_thumb = $get_file;
         }
         \Solunes\Master\App\TempFile::create(['type' => $type, 'folder' => $folder, 'file' => $new_file]);
         $response = ['files' => [['name' => $new_file, 'url' => $get_file, 'thumbUrl' => $get_thumb]]];
         $error_code = 200;
     } else {
         $response = ['error' => $error];
         $error_code = 400;
     }
     return response()->json($response)->setStatusCode($error_code);
 }
开发者ID:solunes,项目名称:master,代码行数:60,代码来源:AssetController.php

示例12: onSaving

 /**
  * A model is saving, check for files being uploaded
  *
  * @param Illuminate\Database\Eloquent\Model $model 
  * @return void
  */
 public function onSaving(Model $model)
 {
     // Check that the model supports uploads through Upchuck
     if (!$this->supportsUploads($model) || !($map = $model->getUploadMap())) {
         return;
     }
     // Loop through the all of the upload attributes ...
     foreach ($map as $key => $attribute) {
         // If there is a file in the input, move the upload to the
         // config-ed disk and save the resulting URL on the model.
         if ($this->request->hasFile($key)) {
             $url = $this->storage->moveUpload($this->request->file($key));
             $model->setUploadAttribute($attribute, $url);
             // Remove the file from the request object after it's been processed.
             // This prevents other models that may be touched during the processing
             // of this request (like because of event handlers) from trying to act
             // on this upload.
             $this->request->files->remove($key);
         }
         // If the attribute field is dirty, delete the old image
         if ($model->isDirty($attribute) && ($old = $model->getOriginal($attribute))) {
             $this->storage->delete($old);
         }
     }
 }
开发者ID:albabar,项目名称:upchuck,代码行数:31,代码来源:Observer.php

示例13: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     // ajax upload
     if ($request->ajax()) {
         // check upload image
         if (!$request->hasFile('uploadImg')) {
             // return json data with error message noImgUpload
             return response()->json(['error' => 'noUploadImg']);
         } else {
             if (!$this->checkImage($request->file('uploadImg'))) {
                 // return json data with error message wrongImgType
                 return response()->json(['error' => 'wrongImgType']);
             } else {
                 if (filesize($request->file('uploadImg')->getPathname()) > 2 * 2 ** 20) {
                     return response()->json(['error' => 'file size is bigger than 2MB']);
                 }
             }
         }
     } else {
         // check has uploadImg or not
         if ($request->hasFile('uploadImg')) {
             // check image content
             if (!$this->checkImage($request->file('uploadImg'))) {
                 // check fail, redirect back with errors
                 return back()->withInput($request->except('uploadImg'))->withErrors('小搗蛋 大頭貼只能選圖片唷:)');
             }
         }
     }
     // pass all check
     return $next($request);
 }
开发者ID:weiyeu,项目名称:laravel_date,代码行数:38,代码来源:CheckUploadImg.php

示例14: uploadImage

 /**
  *Function to upload Profile Image
  */
 public function uploadImage(Request $request)
 {
     if (!$request->hasFile("profile_image") && !$request->hasFile("cover_image")) {
         return redirect()->back()->withErrors(["imageUploaded" => 'image not found']);
     }
     $imageFieldName = $request->hasFile("profile_image") ? "profile_image" : "cover_image";
     $validator = Validator::make($request->all(), [$imageFieldName => 'required']);
     $imageFile = $request->file($imageFieldName);
     $imageExt = $imageFile->getClientOriginalExtension();
     if (array_search(strtolower($imageExt), ['jpg', 'jpeg', 'png', 'gif'])) {
         dd($imageExt);
         return redirect()->back()->withErrors(["imageUploaded" => 'File extension is not supported.']);
     }
     if ($validator->fails()) {
         $errors = $validator->errors();
         dd($errors);
         return redirect()->back()->withErrors($validator->errors());
     }
     $fileName = hash("md5", $imageFile->getClientOriginalName() . Session::get(SiteSessions::USER_ID) . Session::get(SiteSessions::USER_NAME)) . "." . $imageFile->getClientOriginalExtension();
     $userProfile = UserProfile::find(Session::get(SiteSessions::USER_ID));
     $image_type_stored = "";
     //Saving Profile Image
     if ($imageFieldName == "profile_image") {
         //            $image = Image::canvas(300, 300);
         //            $image_updated  = Image::make($imageFile)->resize(300, 300,function($constraint){
         //                $constraint->aspectRatio();
         //            });
         //            $image->insert($image_updated, 'center');
         $image = Image::make($imageFile)->resize(350, 350, function ($constraint) {
             $constraint->aspectRatio();
         });
         $icon_image = Image::make($imageFile)->fit(300, 300)->resize(60, 60);
         $small_image = Image::make($imageFile)->fit(300, 300)->resize(100, 100);
         $this->createImageSourceDirectories(StorageLocationsRepository::USER_DIRECTORY_TYPE_PROFILE_IMAGES);
         $image->save(public_path() . StorageLocationsRepository::USER_PROFILE_IMAGE_PATH . $fileName);
         $icon_image->save(public_path() . StorageLocationsRepository::USER_PROFILE_IMAGE_ICON_PATH . $fileName);
         $small_image->save(public_path() . StorageLocationsRepository::USER_PROFILE_IMAGE_SMALL_PATH . $fileName);
         $userProfile->profile_image_path = url(StorageLocationsRepository::USER_PROFILE_IMAGE_PATH . $fileName);
         $userProfile->profile_icon_image_path = url(StorageLocationsRepository::USER_PROFILE_IMAGE_ICON_PATH . $fileName);
         $userProfile->profile_small_image_path = url(StorageLocationsRepository::USER_PROFILE_IMAGE_SMALL_PATH . $fileName);
         $image_type_stored = "profile_image";
     } else {
         if ($imageFieldName == "cover_image") {
             //            $image = Image::canvas(1200, 350);
             //            $image_updated  = Image::make($imageFile)->widen(1200)->crop(1200,350);
             //            $image->insert($image_updated, 'center');
             $image = Image::make($imageFile)->widen(1200);
             $this->createImageSourceDirectories(StorageLocationsRepository::USER_DIRECTORY_TYPE_COVER_IMAGES);
             $image->save(public_path() . StorageLocationsRepository::USER_COVER_IMAGE_PATH . $fileName);
             $userProfile->profile_cover_image_path = url(StorageLocationsRepository::USER_COVER_IMAGE_PATH . $fileName);
             $image_type_stored = "cover_image";
         }
     }
     $userProfile->save();
     //        return redirect()->back()->with(["imageUploaded"=>"successfully"]);
     Session::put("image_type", $image_type_stored);
     return redirect('profile/' . Session::get(SiteSessions::USER_ID) . '/uploadImageSetting')->with(["imageUploaded" => "successfully"]);
 }
开发者ID:talenthub2015,项目名称:talenthub-website,代码行数:61,代码来源:ProfileController.php

示例15: store

 public function store(Request $request, $id = null)
 {
     $product = null;
     if ($id == null) {
         $product = \App\products::firstOrNew(['SKU' => $request->sku]);
     } else {
         $product = \App\products::find($id);
     }
     $image = null;
     $product->coverImageId = null;
     if ($request->hasFile('coverImage') && $request->file('coverImage')->isValid()) {
         $imageName = 'images/' . $request->file('coverImage')->getClientOriginalName();
         $image = \App\images::firstOrNew(['url' => $imageName]);
         $image->title = $request->file('coverImage')->getClientOriginalName();
         $image->save();
         $request->file('coverImage')->move('images', $imageName);
         $product->coverImageId = $image->id;
     }
     $product->SKU = $request->sku;
     $product->price = $request->price;
     $product->currencyId = $request->currency;
     $product->publishDate = date('Y-m-d', strtotime($request->publishDate));
     $product->cityId = $request->city;
     $product->vendorId = $request->vendor;
     $product->active = $request->Active;
     $product->save();
     $text = \App\stringList::firstOrNew(['alias' => $request->alias]);
     $text->alias = $request->alias;
     $text->title = $request->title;
     $text->description = $request->description;
     $text->condition = $request->condition;
     $text->productId = $product->id;
     $text->languageId = 1;
     $text->save();
     $count = 1;
     $product->images()->detach();
     while (1) {
         $image = null;
         $fileName = 'image' . $count;
         if ($request->hasFile($fileName) && $request->file($fileName)->isValid()) {
             $imageName = 'images/' . $request->file($fileName)->getClientOriginalName();
             $image = \App\images::firstOrNew(['url' => $imageName]);
             $image->title = $request->file($fileName)->getClientOriginalName();
             $image->save();
             $request->file($fileName)->move('images', $imageName);
             $product->images()->attach($image->id);
             $count++;
         } else {
             break;
         }
     }
     return $product->all()->load('text', 'currency', 'coverImage', 'city', 'vendor', 'images');
 }
开发者ID:suhansaha,项目名称:tripAdviser,代码行数:53,代码来源:productController.php


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