컨트롤러와 I는 파일의 위치를 얻을 수 있지만 그것은 단지 임시 위치 대신 원본 파일 경로를 잡아 여기검토 가져 오기 파일 laravel 볼
public function show(Request $request){
$location=$request->file('import_file');
if($request->hasFile('import_file')){
$data = Excel::selectSheets('Sheet1')->load($request->file('import_file'))->noHeading()->toArray();
$result = array(
'data' =>$data,
'page_header' =>'Review Uploaded file',
'location' =>$location,
);
}
return view('admin.floorsheet.list', compact('result'));
}
수입 엑셀.
public function store(Request $request)
{
if($request->hasFile('import_file')){
Excel::load($request->file('import_file')->getRealPath(), function ($reader) {
foreach ($reader->noHeading()->first()->toArray() as $key => $row) {
$data['transaction'] = $row[1];
$data['symbol'] = $row[2];
$data['buyer'] = $row[3];
$data['seller'] = $row[4];
$data['quantity'] = $row[5];
$data['rate'] = $row[6];
$data['amount'] = $row[7];
if(!empty($data)) {
DB::table('tbl_floorsheet')->insert($data);
}
}
});
}
$result = array(
'page_header' =>'File Uploaded',
'date' =>date('Y-m-d'),
);
return view('admin.floorsheet.import',compact('result'));
}
내 색인 페이지 I 성공적보기 페이지에서 테이블의 엑셀 파일을 보여 여기에
<form class="form-horizontal" method="POST" action="{{ route('floorsheet.store') }}" enctype="multipart/form-data">
{{ csrf_field() }}
<div class="col-lg-9 col-md-9 col-sm-12 col-xs-12">
<div class="form-group">
<label for="file">Upload Filer</label>
<input type="file" class="form-control" name="import_file" value="{{$result['location']}}">
</div>
<table class="table table-hover table-responsive table-condensed" >
<tr>
<th>S.No</th>
<th>Transcation No.</th>
<th>Symbol</th>
<th>Buyer</th>
<th>Seller</th>
<th>Quantity</th>
<th>Rate</th>
<th>Amount</th>
</tr>
@foreach($result['data'] as $d)
<tr>
@foreach($d as $v)
<td>{{$v}}</td>
@endforeach
</tr>
@endforeach
</table>
</div>
<div class="clearfix"></div>
<div class="clearfix"></div>
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
<div class="form-group">
<button type="submit" class="btn btn-success">Upload File</button>
<button type="reset" class="btn btn-danger">Reset</button>
</div>
</div>
</form>
<form class="form-horizontal" method="POST" action="{{ route('/my-admin/floorsheet.show') }}" enctype="multipart/form-data">
{{ csrf_field() }}
<div class="col-lg-9 col-md-9 col-sm-12 col-xs-12">
<div class="form-group">
<label for="file">Upload Filer</label>
<input type="file" class="form-control" name="import_file" >
<label for="acceptdate">Date</label>
<input type="text" class="form-control" id="operationdate" name="operationdate" value="{{ $result['date'] }}">
</div>
</div>
<div class="clearfix"></div>
<div class="clearfix"></div>
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
<div class="form-group">
<button type="submit" class="btn btn-success">Upload File</button>
<button type="reset" class="btn btn-danger">Reset</button>
</div>
</div>
</form>
내 목록 페이지. 그러나 뷰 페이지를 사용하여 파일을 업로드하는 동안 파일을 다시 탐색해야합니다. 이제 다시 탐색하지 않고 파일을 업로드해야합니다. 뷰 페이지에서이 값을 사용하면 원본 파일 경로 대신 임시 파일 경로 만 가져옵니다.