0

How can I upload a file in a POST field on my website via curl directly rather using curl in php? In php you can do this with:

<?
$fileupload="image.jpg";
$c = curl_init("file");
curl_setopt($c, CURLOPT_POST, true);
curl_setopt($c, CURLOPT_POSTFIELDS,
array('Filedata'=>"@$fileupload",'folder'=>'/target/'));
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_exec($c);
curl_close($c);
?>

but how can this be done in a linux bash script with curl?

1

1 Answer 1

1

The CURLOPT_POSTFIELDS option sent as a hash array becomes a series of -F uses. Something similar to this:

curl -F [email protected] -F folder=/target/ [URL]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.