Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

lukaserat's avatar

GuzzleHttp/Client file upload, on Laravel Request files not exist

I have found this guzzlehttp and find it amazing on my API calls. Before I am just using php curl for my external http calls. But unfortunately I wasn't able to solve why when I upload large file using guzzlehttp I can't retrieve it using Laravel Input::file thing.

Guys help me to figure this out, Here is my test code:

$printFile = '/home/vagrant/template.tar.gz';
$printData = fopen($printFile, 'r');

$url = url('testing');
$http = new Client;
$options = [
    'verify' => false,
    'debug' => true,
];
$request = $http->createRequest("POST", $url, $options);
$postBody = $request->getBody();
$postBody->setField('ext_order_id', $this->faker->ean8);
// ..bunches of setFields..
// then the file thing..
$postBody->addFile(new PostFile('print', $printData), 'template.tar.gz');
$response = $http->send($request);
$this->assertEquals('OK', $response->getReasonPhrase());

The test goes green. But on the other side, the recipient, I am expecting that the request will contain a file named print, so to verify that I just use this code:

Log::debug([Input::file('print')]);

Unluckily it didn't turns out as I expected not like what I get when the file is not too large.

0 likes
1 reply
lukaserat's avatar
lukaserat
OP
Best Answer
Level 1

Hi folks! I got it now. It's the homestead php ini and nginx configuration that I need to update for this kind of thing. I am wanting to delete this thread because it is not that big deal(i just forget to think the server aspects) for the average but I'll leave this thread if ever someone also encounter this kinda problem.

So what I did is: ...make sure you increase your nginx client_max_body_size directive or just set it to 0 to ignore this rule.

client_max_body_size 0;

...and on your php ini you have two settings to update.

post_max_size = 0
upload_max_filesize = 1G

Note: Setting post_max_size to zero will ignore that rule.

Please or to participate in this conversation.