JavaScript multipart-form data is not retrievable to PHP codeigniter backend-ThrowExceptions

Exception or error:

I’m trying to submit a form with files using javascript to a PHP Codeigniter backend. The javascript code looks like this,

            var card = {
                        user: {
                            my: {
            var form = new FormData()
            form.append('card', card)
            form.append('file', this.user.cover_file)

                method: 'post',
                headers: {'Content-Type': 'multipart/form-data'},
                data: form,
                url: 'url'

And I am unable to retrieve the data from the PHP backend, the backend code looks like this,

public function newpost()
    $user = $this->input->post('user');
    echo $user;

This does not show any output, what am I doing wrong here and why is the data not retrivable from the backend, thanks

How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *