Level 16
MethodNotAllowedHttpException is usually about your routes file...
1 like
Well, I was successfully able to upload a file on my local server. When I switch to the Production Server, I am unable to upload a file and I get this MethodNotAllowedHttpException error.
Also, I am forcing https loads
AppServiceProvider.php
public function boot()
{
if (App::environment('production', 'staging'))
{
URL::forceScheme('https');
}
}
Here is the blade.php file
<form role="form" method="POST" action="update" enctype="multipart/form-data">
@csrf
<div class="box-body">
<div class="form-group">
<label for="exampleInputPassword1">Type</label>
<select class="form-control select2" style="width: 100%;" name="product_id">
@foreach($products as $product)
<option value="{{$product->id}}" @if("{{$product->id}}" === "{{$ProductWorkoutCategory->product_id}}") selected="selected" @endif >{{$product->name}}</option>
@endforeach
</select>
</div>
<div class="form-group">
<label for="exampleInputPassword1">Type</label>
<select class="form-control select2" style="width: 100%;" name="workout_category_id">
@foreach($workout_categories as $category)
<option value="{{$category->id}}" @if("{{$category->id}}" === "{{$ProductWorkoutCategory->workout_category_id}}") selected="selected" @endif >{{$category->title}}</option>
@endforeach
</select>
</div>
</div>
<!-- /.box-body -->
<div class="box-footer">
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</form>
and here is the controller function that update the file and data
$product = Product::find($id);
$product->name = $request->name;
$product->type = $request->type;
$product->category = $request->category;
$product->plan_id = $request->plan_id;
$product->price = $request->price;
$product->picture = $request->file('picture')->store('products','public');
$product->save();
Please or to participate in this conversation.