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: {
firstname: this.user.my.firstname,
lastname: this.user.my.lastname
}
}
}
var form = new FormData()
form.append('card', card)
form.append('file', this.user.cover_file)
axios({
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()
{
$this->load->database();
$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: