I\'m trying to upload multiple files through ajax but I can\'t figure out how to get the uploaded files in PHP. I sent them
var attachments = $(\'.attachment-file
Working solution:
Here's how you send multiple files with ajax.
JS:
var post_data = new FormData();
attachments.each(function(i, v) {
post_data.append('my_file[]', v.files[0]);
console.log(v.files[0]);
});
PHP:
$files = $this->request->files;
$files = $files->get('my_file');
foreach ($files as $file) {
\Log::Info(var_dump_safe($file->getClientOriginalName()));
}
It's all working now.
PS. Don't forget not to post and upload files bigger than the PHP limits of post_max_size and upload_max_size!