lundi 30 juillet 2018

Laravel 5.4 : TokenMismatchException in VerifyCsrfToken.php line 68

When sending a post request When you send a query post, an error occurs TokenMismatchException in VerifyCsrfToken.php line 68.

{!! Form::open( ['route'=>'import.store', 'method'=>'POST', 'class'=>'form-horizontal form-label-left', 'files' => true]) !!}
 {!! Form::label('path', 'Seleccione archivo:', ['class'=>'control-label col-md-3 col-sm-3 col-xs-12']) !!}
 {!! Form::file('path',['required'=>'required', 'class'=>'btn btn-default'])!!}
 {!! Form::submit('Validar', ['class'=>'btn btn-info', 'id'=>'validar', 'name'=>'validar']) !!}
 {!! Form::submit('Cargar', ['class'=>'btn btn-success', 'id'=>'cargar', 'name'=>'cargar']) !!}
{!! Form::close() !!}

html generate

.ENV FILE

APP_ENV=local                                                  
APP_DEBUG=true                                                 
APP_KEY=base64:wMmIEY6XqQu7nbnIRmuURxrKj6V5EL/XCel9xX50/RQ=    
APP_URL=g200603sv07q                                           

DB_CONNECTION=mysql                                            
DB_HOST=localhost                                              
DB_PORT=3306                                                   
DB_DATABASE=encuestas                                          
DB_USERNAME=usr_pro                                            
DB_PASSWORD=Cenco2301.                                         

CACHE_DRIVER=file                                              
SESSION_DRIVER=file                                            
SESSION_DOMAIN=                                                
QUEUE_DRIVER=sync                                              

REDIS_HOST=127.0.0.1                                           
REDIS_PASSWORD=null                                            
REDIS_PORT=6379                                               

My import controller

public function store(Request $request)
{
    $path = $request->file('path');
    $finfo = finfo_open(FILEINFO_MIME);
    $mime = finfo_file($finfo, $path);
    finfo_close($finfo);
    $extension = substr($path->getClientOriginalName(),-3);
    if ($mime=='text/plain; charset=iso-8859-1' && $extension=='csv') {
        $upload = $path->store('csv');
        if ($request->input('validar')) {
            DB::Statement('CREATE TEMPORARY TABLE datatemps LIKE data');
            $this->validar($path);
            flash('Archivo puede ser procesado, se encontraron '.$this->countfiles.' registros')->success();
        }
        elseif ($request->input('cargar')) {
            $this->guardar($path);
            flash('Archivo procesado, se han subido '.$this->countfiles.' registros')->success();
        }
    }
    else {
        flash('Archivo no valido')->error();            
    }
    return view('admin.import');
}

Operating System: CENTOS 7 Laravel 5.4.36 php 7.1



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2Al66q0
via IFTTT

Aucun commentaire:

Enregistrer un commentaire