Rock
Rock

Reputation: 395

FatalErrorException in Laravel: Undefined constant

The code worked fine and also shows output, but the following error prevents it from completing the request:

FatalErrorException in 9b9fbc933495f4e600f4e966ba91c292539fe032.php line 12: Undefined class constant 'close'

enter image description here

Where might the problem be?

This is the compiled view:

<?php $__env->startSection('content'); ?>
<h2>Upload File Here</h2>

<?php echo Form::open(array('url' => '/handleUpload','files' => true)); ?>

    <?php echo Form::file('file'); ?>

    <?php echo Form::token(); ?>

    <?php echo Form::submit('Upload'); ?>

<?php echo Form::close; ?>

<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.master', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>

And these are the original template files:

views/layouts/master.blade.php:

<!DOCTYPE html>
<html>
<head>
    <title>Laravel Upload Tutorial</title>
</head>
<body>
<div class="container">
    @yield('content')
</div>
</body>
</html>

views/files/upload.blade.php:

@extends('layouts.master')

@section('content')
<h2>Upload File Here</h2>

{!! Form::open(array('url' => '/handleUpload','files' => true)) !!}
    {!! Form::file('file') !!}
    {!! Form::token() !!}
    {!! Form::submit('Upload') !!}
{!! Form::close !!}
@endsection

Upvotes: 2

Views: 1476

Answers (2)

Alexey Mezenin
Alexey Mezenin

Reputation: 163938

You've used close in a view instead of close(). Do this:

{!! Form::close() !!}

Upvotes: 3

Tomas Buteler
Tomas Buteler

Reputation: 4137

On the last line below: close is a method, not a constant.

{!! Form::open(array('url' => '/handleUpload','files' => true)) !!}
    {!! Form::file('file') !!}
    {!! Form::token() !!}
    {!! Form::submit('Upload') !!}
{!! Form::close() !!}

Upvotes: 1

Related Questions