laravel-5.3

PostTooLargeException in ValidatePostSize.php line 22 laravel

限于喜欢 提交于 2019-12-19 07:25:19
问题 I am trying to upload a form containing images too. When I submit it. it shows this error PostTooLargeException in ValidatePostSize.php line 22: How do I resolve this issue? 回答1: Check the following parameters in your php.ini file. I've had this issue on several occasions and it's usually because the max_file_size is set to 2M by default. max_file_size upload_max_filesize post_max_size **Edit I was asked how to validate file size using the validate method in Laravel before the file is sent to

PostTooLargeException in ValidatePostSize.php line 22 laravel

一曲冷凌霜 提交于 2019-12-19 07:25:05
问题 I am trying to upload a form containing images too. When I submit it. it shows this error PostTooLargeException in ValidatePostSize.php line 22: How do I resolve this issue? 回答1: Check the following parameters in your php.ini file. I've had this issue on several occasions and it's usually because the max_file_size is set to 2M by default. max_file_size upload_max_filesize post_max_size **Edit I was asked how to validate file size using the validate method in Laravel before the file is sent to

How to set laravel 5.3 logout redirect path?

只谈情不闲聊 提交于 2019-12-18 10:16:34
问题 Is there no elegant solution to redirect to a specific page after logging out in Laravel 5.3? The function being called is from the trait AuthenticatesUsers : public function logout(Request $request) { $this->guard()->logout(); $request->session()->flush(); $request->session()->regenerate(); return redirect('/'); } This is a default function from the core of laravel. So I have to override the whole function I cannot edit the core. But isn't there a more simpler solution, cause it feel like

How to do validation for multiple images upload in laravel 5.3

久未见 提交于 2019-12-18 06:55:02
问题 I've an input <input type="file" name="image[]" multiple="multiple" /> and controller function public function upload(Request $request) { $user_id = Auth::user()->id; foreach ($request->image as $image) { $this->validate($request,[ 'image' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048' ]); $imageName = mt_rand() .time().'.'.$image->getClientOriginalExtension(); $img = Image::make($image->getRealPath()); $img->resize(100, 100, function ($constraint) { $constraint->aspectRatio(); })-

Laravel 5 - Compile String and Interpolate Using Blade API on Server

旧街凉风 提交于 2019-12-18 05:59:13
问题 Using the Blade service container I want to take a string with markers in it and compile it down so it can be added to the blade template, and further interpolated. So I have an email string (abridge for brevity) on the server retrieved from the database of: <p>Welcome {{ $first_name }},</p> And I want it to interpolated to <p>Welcome Joe,</p> So I can send it to a Blade template as $content and have it render all the content and markup since Blade doesn't interpolate twice and right now our

Laravel: blade foreach looping bootstrap columns

走远了吗. 提交于 2019-12-18 04:38:07
问题 I have a foreach loop and inside that contains html with bootstrap columns. @foreach($address as $add) <div class="col-md-6"> Some data </div> @endforeach However, bootstrap requires the row div before creating columns, placing that straight in to the foreach loop would create a row div for each col-md-6. I want to know how I can throw in the row div, skip the next loop throwing in only the closing div tag. And then repeat that process. Example output where the loops 4 times: <div class="row"

Retrieving image stored in storage folder

£可爱£侵袭症+ 提交于 2019-12-17 21:33:13
问题 Using laravel 5.3, I am trying to retrieve an image in a view. How I could do this? folder structure: storage/app/avatard Here is the code: public function storeAvatar(Request $request, $username) { $user = User::where('name', $username)->first(); $avatar = $request->file('avatar')->store('avatars'); $avatar = explode('avatars/', $avatar); $user->user_setting()->updateOrCreate( ['user_id' => $user->id], ['avatar' => $avatar[1]] ); return back(); } This is how the image path is saved in the

Laravel 5.3 - How to add Sessions to `API` without CSRF?

这一生的挚爱 提交于 2019-12-17 21:18:01
问题 Im trying to build an api , and for some reason I need sessions. But if I include web middleware I get CSRF errors, and if I dont I cant have session started. How to solve this? 回答1: go to app/Http/Kernel.php and add your own name like 'sessions' to the $middlewareGroups. It should contain \Illuminate\Session\Middleware\StartSession::class, Assign 'sessions' to those routes you want. protected $middlewareGroups = [ 'web' => [ \App\Http\Middleware\EncryptCookies::class, \Illuminate\Cookie

How to use API Routes in Laravel 5.3

我只是一个虾纸丫 提交于 2019-12-17 17:52:59
问题 In Laravel 5.3 API routes were moved into the api.php file. But how can I call a route in api.php file? I tried to create a route like this: Route::get('/test',function(){ return "ok"; }); I tried the following URLs but both returned the NotFoundHttpException exception: http://localhost:8080/test/public/test http://localhost:8080/test/public/api/test How can I call this API route? 回答1: You call it by http://localhost:8080/api/test ^^^ If you look in app/Providers/RouteServiceProvider.php you

How to update data on a page without refreshing on the vue.js?

我怕爱的太早我们不能终老 提交于 2019-12-17 16:54:24
问题 My view is like this : <div class="favorite" style="margin-bottom:5px;"> @if (Auth::user()) <add-favorite-store :id-store="{{ $store->id }}"></add-favorite-store> @else <a href="javascript:" class="btn btn-block btn-success"> <span class="fa fa-heart"></span> Favorite </a> @endif </div> My component is like this : <template> <a href="javascript:" class="btn btn-block btn-success" @click="addFavoriteStore($event)"> <span class="fa fa-heart"></span> <label id="favoriteId">{{ store_id ==