raducu.mirescu
1 year ago
1168
3
Requests

Laravel 5.6 request->file returns null and cannot store files

Posted 1 year ago by raducu.mirescu

I'm trying to upload files from my app but for some reasons I get " Call to a member function store() on null ". I have created the storage:link.

This is my view:


<div class="container">
    <div class="row justify-content-center">
        <div class="col-md-8">
            <form action="/upload" method="post">
        @csrf                
                <input type="file" name="xml">
                <input type="Submit" class="btn btn-primary" value="Send">
            </form>
        </div>
    </div>
</div>

And my controller:

public function upload(Request $req)
{   

    $path = $req->file('xml')->store('xml');

    return $path;
}

Is there something I'm missing or doing wrong?

Thank you!

Please sign in or create an account to participate in this conversation.