1

I'm trying to send a zip file using guzzle but all the tuts I found have failed.

Things I have tried :

$body = fopen('compress.zlib://http://www.example.com/myarchive.gz', 'rb');
$client->request('POST', 'upload-endpoint', ['body' => $body]); 

Also using multipart :

$res = $client->request('POST', $this->base_api . $endpoint, [

'auth'      => [ env('API_USERNAME'), env('API_PASSWORD') ],
'multipart' => [
    [
        'name'     => 'FileContents',
        'contents' => file_get_contents($path . $name),
        'filename' => $name
    ],
    [
        'name'     => 'FileInfo',
        'contents' => json_encode($fileinfo)
       ]
   ],
]);

But I get data in $_POST like FileInfo and nothing in $_FILES. I don't know if this is even possible to do using guzzle if no is there a way I can do this using Curl ?

Edit: I tried doing it like in this question but this is for normal files not ZIP. That is causing me problems , because all i get is Resource id #some-number.

SergejV
  • 468
  • 1
  • 8
  • 18
  • 3
    Possible duplicate of [Upload file using Guzzle 6 to API endpoint](https://stackoverflow.com/questions/38133244/upload-file-using-guzzle-6-to-api-endpoint) – Mike Doe May 24 '18 at 06:45
  • The OP tried the solution in the suggested duplicate, but it doesn't work. – jmarkmurphy May 24 '18 at 14:22
  • @emix , I tried this before you marked as duplicate , second part of question is from that question [Upload file using Guzzle 6 to API endpoint](https://stackoverflow.com/questions/38133244/upload-file-using-guzzle-6-to-api-endpoint) . – SergejV May 29 '18 at 13:03

0 Answers0