V
V
Volodymyr2022-03-11 18:12:28
PHP
Volodymyr, 2022-03-11 18:12:28

How to generate a CSV file and send it as a POST request without saving it?

Hello!
Tell me how to generate a CSV file and send it with a POST request without saving it?
How to generate is clear, but how to send the generated data via Guzzle or Http Client to Laravel without saving the file?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
nokimaro, 2022-03-11
@volodyalesha86

You can send a file to guzzle using multipart
https://docs.guzzlephp.org/en/stable/request-optio...
while the contents of the file itself can be a string: parametercontents

$csv_data = 'xxxx;yyy;zzz';

$client->request('POST', '/post', [
    'multipart' => [
        [
            'name'     => 'mycsv',
            'contents' => $csv_data,
            'filename' => 'custom_filename.csv'
        ],

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question