Я хочу подтвердить, что пользователь может загружать только лист Excel в форме. Для этого я попробовал mimes:xls,xlsx в правилах, но у меня это не сработало.
А также всякий раз, когда я редактирую данные формы заполнения, он показывает мне только заголовок, но не показывает имя загружаемого файла. он всегда показывает мне, что файл не выбран. Я загрузил скриншот этого.
Любая помощь в этом? !!! Спасибо :)
Файл Controller.php
public function store()
{
$uploadsheet = Request::all();
$rules = array(
'title'=>'required',
'graph_sheet'=>'required|mimes:xls,xlsx'
);
$validator = Validator::make($uploadsheet,$rules);
if ($validator->fails())
{
// $messages = $validator->messages();
return Redirect::to(url('/uploadsheet/create'))->withInput()->withErrors($validator);
} else {
$imageName='';
if(Request::file('graph_sheet')!='') {
$imageName = Request::file('graph_sheet')->getClientOriginalName();
$destinationPath = "upload/sheet/";
Request::file('graph_sheet')->move($destinationPath, $imageName);
}
Uploadsheet::create(['title' => $uploadsheet['title'],'graph_sheet' => $imageName]);
return redirect('uploadsheet');
}
}
------------------------------ код edituploadsheet.blade.php ------------------
@extends('app')
@section('content')
<?php if(count($errors)!='0') { ?>
<div class="alert alert-danger">
<?php foreach($errors->all() as $err) { ?>
<?php echo $err;?><br/>
<?php } ?>
</div>
<?php } ?>
<h1>Update Content</h1>
{!! Form::model($uploadsheet,['method' => 'PATCH','route'=>['uploadsheet.update',$uploadsheet->id],'files'=>true]) !!}
<div class="form-group">
{!! Form::label('Title', 'Title:') !!}
{!! Form::text('title',null,['class'=>'form-control']) !!}
</div>
<div class="form-group">
{!! Form::label('Graph Sheet', 'Graph Sheet:') !!}
{!! Form::file('graph_sheet',null,['class'=>'form-control']) !!}
</div>
<div class="form-group">
{!! Form::submit('Update', ['class' => 'btn btn-primary']) !!}
</div>
{!! Form::close() !!}
@stop
{!! Form::file('graph_sheet') !!}
вместо{!! Form::file('graph_sheet',null,['class'=>'form-control']) !!}
- person Saad   schedule 09.11.2015