I've never done any curl before so am in need of some help.
php:
<?php
$ch = curl_init();
$data = array(
'uptype'=>'file',
'file'=>'@'.$argv[1],
);
curl_setopt($ch, CURLOPT_URL, 'http://my_site_ex/up.php');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_exec($ch);
curl_close($ch);
?>
how to make the same script in BASH?
I believe it's:
curl -F "uptype=file" -F "file=@$1" 'http://my_site_ex/up.php'
The -F uses multipart/form-data, which the PHP interface libcurl uses if you pass an array for CURLOPT_POSTFIELDS. Each -F is a separate field. libcurl reads the file you specify with @
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With