ssboopathi1991's avatar

PHP GuzzleHttp . how to upload the image file using guzzlehttp in laravel 5.2?

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

0 likes
0 replies

Please or to participate in this conversation.