2016-04-25 12 views
0

これは私が尋ねた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()); 




    } 

、ここでは私のルート

<?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 

任意の提案だ私のコントローラのですか? 編集:ここに私の要求がある\ 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', 

     ]; 
    } 
} 
+0

これは、失敗している 'Requests \ CreateItem'の中にあるはずです。関連するコードを表示することはできますか? – user3158900

答えて

0

私はあなたがこの行を削除すべきだと思う、すべての最初のファイル:あなたがルートにsomethinkを変更したい場合は

Route::post('/item/create', ['as' => 'item.store', 'uses' => '[email protected]']);

を(名前またはコントローラメソッド)あなたは、この行の前に置く必要があります。

Route::resource('item', 'ItemController');

あなたの敗走あなたがフォームに戻った理由は間違っています。

0

私は私の答えを見つけたかもしれないと思います。 'filename', 'required|min:7',filename => 'required|min:7'でなければならない

関連する問題