ghaonga's avatar

Route not found

Hello I need help. I have two pages one upload and the second is fileupload. The upload file displays the data of files from the database and the fileupload contains upload form. Whenever I insert route on form action, i get the error Symfony\Component\Routing\Exception\RouteNotFoundException Route [/save-file] not defined. Please I need your help. Here are my codes: Upload.blade.php

     @extends('layouts.studentlayout')
     @section('title')
       Project Dashboard
     @endsection
     @section('content')
     <!-- add the box modal -->
     <!-- Button trigger modal -->
   <div class="row">
    <div class="col-md-12">
     <div class="card">
      <div class="card-header">
        <h4 class="card-title"> Add Project Title
        <a href="{{ route('/fileupload') }}" class="btn btn-success">Add</a>
        </h4>
    <!--this code will dispay message from projectcontroller for status-->
  @if(session('status'))
  <div class="alert alert-success" role="alert">
    {{session('status')}}
  </div>
@endif
      </div>
      <div class="card-body">
        <div class="table-responsive">
          <table id="datatable" class="table table-stripped">
            <thead class=" text-primary">
              <th>ID</th>
              <th>Name</th>
              <th>Description</th>
              <th>EDIT</th>
            </thead>
            <tbody>
              @foreach($files as $file)
              <tr>
                <td>{{$file->id}}</td>
                <td>{{$file->filename}}</td>
                <td>{{$file->type}}</td>
                <td>{{$file->size}}</td>
                <a href="javascript:void(0)" class="btn btn-danger" data-toggle="modal" data-target="#deletemodal">Delete</a>
                </td>
              </tr>
               @endforeach
            </tbody>
          </table>
        </div>
      </div>
    </div>
  </div>
</div>

@endsection @section('scripts') @endsection

fileupload.blade.php

@extends('layouts.studentlayout')
@section('title')
Project Edit Dashboard
    @endsection
   @section('content')
      <div class="row">
        <div class="col-md-12">
          <div class="card">
             <div class="card-header">
                 <h4 class="card-title"> File Upload</h4>
                   //errors display from the file controller
                       @if($errors->any())
     <div class="alert alert-danger">
       <ul>
            @foreach($errors->all() as $error)
            <li>{{$error}}</li>
              @endforeach
        </ul>
     </div>
     @endif
         <!-- we add a form -->
         <form action="{{ route('/save-file')}}" method="post" enctype="multipart/form-data" >
           @csrf
           <div class="modal-body">
           <div class="row mb-3">
                 <label for="type">Submission Type</label>
                   <div class="col-md-3">
                        <select id="select" aria-label="Default select example" name="type" required autocomplete="level" autofocus>
                            <option value="" selected>Select Submission Type</option>
                            <option value="proposal">Proposal (docx)</option>
                            <option value="presentation">Presentation (PPT)</option>
                            <option value="report">Report (docx)</option>
                     </select>

                    </div>
                 </div>
       <div class="fileinput fileinput-new" data-provides="fileinput">
    <div>
         <span class="btn btn-raised btn-round btn-default btn-file">
                  <input type="file" name="filename" class="form-control" accept=".jpg,.jpeg,.bmp,.png,.gif,.doc,.docx,.csv,.rtf,.xlsx,.xls,.txt,.pdf,.zip" /></span>
 <br />
 <a href="#pablo" class="btn btn-danger btn-round fileinput-exists" data-dismiss="fileinput">Upload</a>
  </div>
   </div>
</form>
       </div>
     </div>
   </div>

@endsection

My route (web.php)

    Route::get('/upload', 'App\Http\Controllers\Student\FilesController@index');
    Route::get('/fileupload','App\Http\Controllers\Student\FilesController@create');
    Route::post('/save-file','App\Http\Controllers\Student\FilesController@store');
0 likes
4 replies
Sinnbeck's avatar

The route() helper takes the name of the route, not the url. So just remove it

<form action="/save-file" method="post" 
ghaonga's avatar

Thank you all for the help. I really appreciate. I hustled on this for 2 days

Sinnbeck's avatar

@ghaonga always feel free to ask here if you are stuck. Mark the answer you liked the best as best answer to mark the thread as solved :)

Please or to participate in this conversation.