Are you sure it's a Laravel problem ?
What error do you get ?
According to the code you show here, it seems that you mix both Javascript and PHP.
Hi everyone. API that worked in node js is not working in http client
const file = await fs.readFile('test.csv', {encoding: 'utf8'})
const group_data = new FormData()
group_data.append('display', 'broadcast')
group_data.append('action', 'group')
group_data.append('edit', false)
group_data.append('editCallee', '')
group_data.append('MAX_FILE_SIZE', '19922944')
group_data.append('name', 'test')
group_data.append('uri', '')
group_data.append('ftpdelete', 0)
group_data.append('update_period', ''),
group_data.append('csv', file)
await axios.post(
"{url}",
group_data,
{
headers: {
"Content-Type": "multipart/form-data"
}
}
).then(res => {
// console.log('res: ', res.data);
console.log('Succesfully added group !!!');
});
Http::withHeaders([
'Content-Type' => 'multipart/form-data',
])->attach('csv', file_get_contents(public_path('test.csv')), 'test.csv')->post(
"{url}",
[
'display' => 'broadcast',
'action' => 'group',
'edit' => false,
'editCallee' => '',
'MAX_FILE_SIZE' => '19922944',
'name' => $name,
'uri' => '',
'ftpdelete' => '0',
'update_period' => ''
]
);
Please or to participate in this conversation.