Support the ongoing development of Laravel.io →
Forms Validation

How make post request with GuzzleHttp( version 6.0 ). I am trying do the following and getting error

i'm get the image value

Illuminate\Http\UploadedFile Object
(
    [test:Symfony\Component\HttpFoundation\File\UploadedFile:private] => 
    [originalName:Symfony\Component\HttpFoundation\File\UploadedFile:private] => 1.53mb.jpg
    [mimeType:Symfony\Component\HttpFoundation\File\UploadedFile:private] => image/jpeg
    [size:Symfony\Component\HttpFoundation\File\UploadedFile:private] => 1607671
    [error:Symfony\Component\HttpFoundation\File\UploadedFile:private] => 0
    [pathName:SplFileInfo:private] => C:\wamp\tmp\php32BB.tmp
    [fileName:SplFileInfo:private] => php32BB.tmp
)

here i'm using guzzlehttp using to upload the image

$response = $this->client->request('POST', url('/update_profile'), [
    'multipart' => [
        [
            'name'     => 'foo',
            'contents' => fopen('C:\wamp\tmp\php32BB.tmp', 'r'),//this path is image save temperary path
        ]
    ]
]);

Now i get the error fopen(C:\wamp\tmp\php17BC.tmp): failed to open stream: No such file or directory.

How to use the contents in multipart

Last updated 2 years ago.
0

i solved this issue

$image_path = $post_array['image']->getPathname();
$image_mime = $post_array['image']->getmimeType();
$image_org  = $post_array['image']->getClientOriginalName();

$response = $this->client->post(url('/update_profile'), [
			'multipart' => [
    			[
    				'name'     => 'image',
    				'filename' => $image_org,
    				'Mime-Type'=> $image_mime,
    				'contents' => fopen( $image_path, 'r' ),
    			],
    		]
    	]);
Last updated 8 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.