Это вопрос, который я задал после вопроса previous. Я добавил код в соответствии с инструкциями, но теперь все, что я получаю, когда моя форма попадает в поле загрузки, я просто перенаправляю bacl в форму.laravel - файл не загружается в папку загрузок
Вот мое мнение:
@extends('app');
@section('content');
<h1>Add a new item</h1>
<hr />
<content>
<div class="form-group">
{!! Form::open(['route' => 'item.store', 'files' => true]) !!}
{!! Form::label('name', "Name") !!}
{!! Form::text('name', null, ['class' => 'form-control']) !!}
{!! Form::label('filename', "File Name") !!}
{!! Form::file('filename', null, ['class' => 'form-control']) !!}
{!! Form::label('description', 'Description') !!}
{!! Form::textarea('description', null, ['class' => 'form-control']) !!}
{!! Form::submit('Add Item', ['class' => 'btn btn-primary form-control']) !!}
</content>
</div>
@stop
Вот мой контроллер
public function store(Requests\CreateItem $request)
{
Item::create($request->all());
// if (Input::hasFile('filename')) {
// $file = $request->file('filename');
// $file->move(public_path().'/uploads', $file->getClientOriginalName());
//
// echo "File Uploaded";
//
// }
dd(Input::all());
}
и вот мои Routes
<?php
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
Route::resource('item', 'ItemController');
Route::get('/', function() {
return view('welcome');
});
Route::auth();
Route::get('/home', '[email protected]');
Route::post('/item/create', ['as' => 'item.store', 'uses' => '[email protected]']);
Route::get('/item', '[email protected]');
//Route
Любые предложения? Edit: здесь мои запросы \ CreateItem.php файл
<?php
namespace App\Http\Requests;
use App\Http\Requests\Request;
class CreateItem extends Request
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true; // for now
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'name' => 'required|min:3',
'filename', 'required|min:7',
];
}
}
Это должно быть что-то в 'Requests \ CreateItem', который терпит неудачу. Можете ли вы показать нам какой-то соответствующий код? – user3158900