Reputation: 25
i am trying to upload an image to imagezilla.net in java. with php using curl it´s no problem..
$pvars = array('file' => "@".$imagePath, 'apikey' => "apikey");
$timeout = 30;
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'http://imagezilla.net/api.php');
curl_setopt($curl, CURLOPT_TIMEOUT, $timeout);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $pvars);
$xml = curl_exec($curl);
curl_close ($curl);
$res = new SimpleXMLElement($xml);
how is it possible to do this in java?
Upvotes: 0
Views: 339
Reputation: 6536
You can use Apache HTTPComponents . It is a bit more complicated than cURL, but, it will do the job (you basically have to fill out a form and POST it).
Upvotes: 1