0

I'm trying to upload images to laravel and I'm having some trouble :S

My view:

<form role="form" method="post" action="{{url('admin/test')}}" id="formm" >
        <input  type="file" placeholder="browse" id="imagen_item" name="imagen_item" accept="image/*"/>
        <input type="submit" style="font-size: 20px" class="btn btn-primary" value="Guardar">
</form>

My routes.php

Route::post('admin/test','AdminController@test');

My Controller

public function test()
{
    $file = Input::file('imagen_item');
    var_dump($file);
    $destinationPath = 'uploads/';
    if(is_object($file))
    {
        $filename = $file->getClientOriginalName();
        $upload_success = Input::file('imagen')->move($destinationPath, $filename);
        if( $upload_success ) {
            echo 'save this url: '.$filename." in the DB";
        }
    }
}

And what I get after submitting the form:

null
A
A.A

So obvously the problem is the I'm not thetting the image from the input form.. but why?? I have the same name... Thank you!

1 Answer 1

1

Solved! I changed the form tag for:

    {{ Form::open(array('url' => 'admin/rnew_item', 'files' => true,'id'=>'formm')) }}

and ofc the for:

    {{ Form::close() }}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.