Can you do exactly as described in docs? https://laravel.com/docs/12.x/http-client#multi-part-requests
Oct 18, 2025
2
Level 27
PHP equivalent of cURL
This command lets me upload a file to my Laravel controller using cURL and I was able to get the file in Laravel using $request->file("files")
curl \
-F "action=notify" \
-F "files[][email protected]" \
--fail-with-body \
https://example.com/upload
What is the equivalent in Laravel? I have tried both asForm and asMultipart and did not work, the controller was executed, but $request->file("files") had no files
$url = "https://example.com/upload";
$path = storage_path("text-file.txt");
$response = Http::withHeaders([])
->asForm()
// ->asMultipart()
->attach('files[]', File::get($path), File::basename($path))
->post($url, [
[
'name' => 'action',
'contents' => 'notify',
],
]);
Please or to participate in this conversation.