Я начинающий для laravel, и я запускаю систему emp mangment. Я хочу загрузить изображение сотрудника в свой профиль сотрудника в режиме добавления и режиме редактирования. Ошибка .my - когда я отправляю данные в контроллер, появляется сообщение об ошибке Msg. Указанные данные были неверными.
Iam Using.
laravel 5.4
Xampp V3.2.4
Php 7.3.12
Это моя форма Pos-вкладки
<div class="pos-tab-content active">
<div class="row-e">
<div class="col-sm-1-e">
{!! Form::label('empNo', __('employee.empno') . ':*',['class' => 'label-control']) !!}
</div>
<div class="col-sm-2-e">
<div class="form-group">
{!! Form::text('empNo',isset($emp->empNo) ? $emp->empNo : null , ['class' => 'emp-control','autocomplete'=>'off']); !!}
</div>
</div>
<div class="col-sm-0-e">
{!! Form::label('empEPFNo', __('employee.epfno') . ':*',['class' => 'label-control']) !!}
</div>
<div class="col-sm-2-e">
<div class="form-group">
{!! Form::text('empEPFNo',isset($emp->empEPFNo) ? $emp->empEPFNo : null , ['class' => 'emp-control', 'autocomplete'=>'off']); !!}
</div>
</div>
<div class="col-md-6">
<input type="file" name="image" class="form-control">
</div>
<div class="clearfix"></div>
**Other Form Control In there**
</div>
</div>
Это главная форма
@extends('layouts.emp')
<div class="modal-dialog modal-lg" id = "employee_modal" role="document">
<div class="modal-content">
@if(isset($emp))
{!! Form::open(['url' => action('EmployeeController@update', [$emp->empID]), 'method' => 'PUT','files' => true , 'id' => 'employee_edit_form','files' => true]) !!}
@else
{!! Form::open(['url' => action('EmployeeController@store'), 'method' => 'post','files' => true , 'id' => 'employee_add_form','files' => true ]) !!}
@endif
<div class="modal-header" id="employeemodal_header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="employeemodal_title">@lang('employee.add_employee')</h4>
</div>
<div class="modal-body" id="employee_modal_body">
<!-- Main content -->
<div class="row-e">
<div class="col-xs-12">
<!-- <pos-tab-container> -->
<div class="col-xs-12 pos-tab-container">
<div class="pos-tab-menu">
<div class="list-group list-group-horizontal">
<a href="#" class="list-group-item text-center active">@lang('employee.genaral')</a>
<a href="#" class="list-group-item text-center">@lang('employee.bank')</a>
<a href="#" class="list-group-item text-center">@lang('employee.addition') </a>
<a href="#" class="list-group-item text-center">@lang('employee.leaves')</a>
<a href="#" class="list-group-item text-center">@lang('employee.identity')</a>
<a href="#" class="list-group-item text-center">@lang('employee.contact')</a>
</div>
</div>
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 pos-tab">
<!-- tab 1 start -->
@include('employee.partials.empadd')
<!-- tab 1 end -->
@include('employee.partials.bank')
<!-- tab 2 start -->
@include('employee.partials.addition')
<!-- tab 2 end -->
<!-- tab 3 start -->
@include('employee.partials.leave')
<!-- tab 3 end -->
<!-- tab 4 start -->
@include('employee.partials.identity')
<!-- tab 4 end -->
<!-- tab 5 start -->
@include('employee.partials.contact')
<!-- tab 5 end -->
</div>
</div>
<!-- </pos-tab-container> -->
</div>
</div>
<div class="row-e">
</div>
</div>
<div class="modal-footer" id="employee_modal_footer">
<button type="submit" class="btn btn-primary" id="empsubmit">@lang( 'messages.save' )</button>
<button type="button" class="btn btn-default" data-dismiss="modal">@lang( 'messages.close' )</button>
</div>
{!! Form::close() !!}
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
<script>
$(document).ready(function(){
$("#employee_modal").draggable({
handle: "#employeemodal_header"
});
$('.modal.draggable>.modal-dialog').draggable({
cursor: 'move',
handle: '.modal-header'
});
$('.modal.draggable>.modal-dialog>.modal-content>.modal-header').css('cursor', 'move');
$('#empsubmit').click(function(){
$('#empPicPath_u').val($('#empPicPath').attr('src'))
})
// $("#employee_modal").draggable({
// handle: ".modal-header"
// })
});
</script>
<style>
.modal {
text-align: center;
padding: 0!important;
}
.select2-results{
text-align: left !important;
}
.modal:before {
content: '';
display: inline-block;
height: 100%;
vertical-align: middle;
margin-right: -4px;
}
.modal-dialog {
display: inline-block;
text-align: left;
vertical-align: middle;
}
#employeemodal_header{
background-color: #3c8dbc;
color:#ffffff;
max-height:20px;
}
#employeemodal_title {
margin: -15px -3px;
line-height: 1.42857143;
}
.close{
float: right;
font-size: 21px;
font-weight: 700;
line-height: 0!important;
padding-right: 5px!important;
color: #000;
text-shadow: 0 1px 0 #fff;
filter: alpha(opacity=20);
opacity: .2;
}
#employee_modal_footer {
margin-top: 474px;
padding: 6px;
text-align: right;
border-top: 1px solid #e5e5e5;
}
#employee_modal_body {
position: relative;
padding-top: 1px;
padding-bottom: 15px;
padding-left: 15px;
padding-right: 15px;
margin-bottom: 0px !important;
}
</style>
Это моя jquery
$(document).on('submit', 'form#employee_add_form', function(e) {
e.preventDefault();
var data = $(this).serialize();
$.ajax({
method: 'POST',
url: $(this).attr('action'),
dataType: 'json',
data: data,
success: function(result) {
if (result.success == true) {
$('div.employee_modal').modal('hide');
$('body').removeClass('modal-open');
$('.modal-backdrop').remove();
employee_table.ajax.reload();
}else{
console.log('error)}
});
});
Это мой контролер
public function store(Request $request)
{
if (!auth()->user()->can('employee.create')) {
abort(403, 'Unauthorized action.');
}
DB::beginTransaction();
try {
$input = $request->only(['empNo', 'empEPFNo','empName','empDOB','empNameFull','subID','deptID',
'actID','desigID','etID','egraID','mariID','pgID','bra_cityID','empIDCardNo','empSex',
'empBasicSalary','empDOJ','natID','relID','empPassportNo','empDrivLicenseNo','empInsuranceNo',
'empBloodGroup','intvID','vacID','empComments','empTempAddress','empTempPhoneH','empTempContPerson',
'empAddress','empPhoneH','empContPerson','empPhoneM','empEmail','empRoute','cityID','cityID_div','bankbranchID',
'bankID','ebAccNo','empAutoPresent','empEarlyOT','empExists','empAtt','empPayroll','emppaymentmode']);
$input['compID'] = $request->session()->get('user.business_id');
$input['created_by'] = $request->session()->get('user.id');
$input['created_at'] = \Carbon\Carbon::now(); # new \Datetime()
$compID = request()->session()->get('user.business_id');
$empID =DB::table('hrms_tbl_employee')->where('compID',$compID)->max('empID');
if ($empID ==null){
$empID = 0;
}
$empID = $empID + 1;
$input['empID'] = $empID;
// $employee = hrms_tbl_employee::create($input);
$request->validate([
'image' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048',
]);
$imageName = time().'.'.$request->image->extension();
$request->image->move(public_path('images'), $imageName);
$employee = DB::table('hrms_tbl_employee')->insert($input);
**last point is image validation part...**
Если кто-нибудь может дать мне совет, его воля Большая помощь для меня Спасибо.!