jeudi 1 décembre 2016

laravel 5 won't delete files from storage section

when I try to delete specific file trough my controller i get an error

Sorry, the page you are looking for could not be found. NotFoundHttpException

this is my controller

public function destroyFile($file_name)
{
    $file = storage_path('documents').'/'.$file_name;
    Storage::delete($file);
    return redirect('/documents');
}

route

  Route::delete('documents/{file}','FilesController@destroyFile');

and view

    {!! Form::open(['method' => 'DELETE', 'action' =>     ['FilesController@destroyFile', $file->name] ]) !!}
                            {!! Form::hidden('_method', 'DELETE') !!}
                            {!! Form::token() !!}
                            {!! Form::submit(trans('buttons.del-cat'),['class'=>'btn btn-danger user-delete push-right']) !!}
                            {!! Form::close() !!}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire