G
G
germn2013-01-21 09:40:46
PHP
germn, 2013-01-21 09:40:46

Is it possible to send a string with curl as a file?

It is necessary to send a file as one of the POST parameters. Usually done with @ , like so:

$post = array(
        "file_to_upload"=>"@/path/to/myfile.jpg",
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post); 


I have the content of myfile.jpg in a variable and would like to avoid saving it to a temporary file on disk.

Is it possible to do this?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Beresnev, 2013-01-21
@germn

POST a file string using cURL in PHP?

A
Alexander Borisovich, 2013-01-21
@Alexufo

base64 encode?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question