samedi 20 août 2016

Input::hasFile() not working

I am trying to check if the image that i am trying to upload is getthing processed, but when i try to use de Input::hasFile('upimg') to check it out it doesnt do anything. This is my form:

{!! Form::open(array('route' => array('uploadimage'), 'method' => 'POST')) !!}
                    {!! csrf_field() !!}
                    <div class="form-group">
                        {!! Form::label('newimg', 'Choose Image to upload:', ['class' => 'control-label']) !!}
                        {!! Form::file('upimg', null) !!}
                    </div>
                    <div class="form-group">
                        {!! Form::label('directory', 'Choose directory:', ['class' => 'control-label']) !!}
                        {!! Form::select('newimage', [ '' => 'none'] + $imagesdir , '', ['class' => 'form-control']) !!}
                    </div>

                    {!! Form::submit('Upload', ['class' => 'btn btn-primary']) !!}

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

And this is the code i am using to check the file:

public function doUpload()
{
   if (Input::hasFile('upimg')){
      echo 'uploaded';
   }; 
}

As you can see i am trying to check:

{!! Form::file('upimg', null) !!}

If i am not wrong its suppose to give mi back the echo but nothing happens. Why is this not working? what am i doing wrong?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire