Last active
June 13, 2022 18:50
-
-
Save gundamew/f04bdf2e2850eb73df2621d67f1fef32 to your computer and use it in GitHub Desktop.
Download/Upload files with Guzzle.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$client = new GuzzleHttp\Client(); | |
// Ref: https://guzzle.readthedocs.io/en/latest/request-options.html#sink-option | |
$client->request('GET', 'http://example.com', [ | |
'sink' => '/tmp/' . sha1(file_get_contents('https://example.com')) | |
]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$client = new GuzzleHttp\Client(); | |
$client->request('POST', 'https://example.com', [ | |
'multipart' => [ | |
[ | |
'name' => 'foo', | |
'contents' => fopen('/path/to/file', 'r'), | |
], | |
], | |
]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment