gayathri's avatar

Image upload

Hi, I am uploading a image. First, It gives me trouble. Then, I included then it works fine.. Now the problem is, I moved the sessions from file to database while performing this I got an error "Token Mismatch Exception in VerifyCSRFToken.php". Give me a solution please.

0 likes
11 replies
mstnorris's avatar

@gayathri please take a look at the Guidelines for posting.

When you get a Token Mismatch Exception that's because you probably haven't included the token in your form.

Inside your <form> </form> tags, add the following: (remove the spaces between the braces)

{ { csrf_field() } }

I say probably as you haven't given us nearly enough information, no code. We can't help you if you don't help yourself. When asking questions, ask yourself, if it was the other way around, what would I need from this person in order to help them out. If you wouldn't know where to start, then provide more information. :)

gayathri's avatar

This is my code name="_token" content="{{{csrf_token()}}}" in my input field.

veve286's avatar

did u migrate your session table ? did u dump-autoload your composer ? when u switch your session driver.


php artisan session:table
composer dump-autoload
php artisan migrate

bashy's avatar

Check in your browser (network tab in developer tools) that the _token field gets sent with the POST request.

gayathri's avatar

@mstnorris

my form code:

No Image
Hide

my route: Route::post('apply/upload', array('as' => 'apply/upload', 'uses' => 'ImageUploadController@store'));

It is working but when i change session drive from file to table it show the following error

error:Token Mismatch Exception verify csrftoken.php line 46

veve286's avatar

try this


php artisan cache:clear
php artisan clear:compiled
sudo service apache2 restart

Please or to participate in this conversation.