I have a web application that I need to send a CURL command from a HTTP URL to an application which is running on Ubuntu.
The curl command is this:
curl -X POST --data-binary @/home/User/Pastec_FYP/Currency_Test_Images/Test_TenEuro.jpg http://127.0.0.1:4212/index/searcher
The command is getting an image from the following:
And it is searching through the index at
I need to be able to translate that to PHP.
This is what I got so far, but it's still saying
$ch = curl_init(); $post = array( "file" => "@" .realpath("/home/User/Pastec_FYP/Currency_Test_Images/Test_TenEuro.jpg") ); curl_setopt_array( $ch, array( CURLOPT_URL => 'http://127.0.0.1:4212/index/searcher', curl_setopt($ch, CURLOPT_POSTFIELDS, $post), CURLOPT_RETURNTRANSFER => true )); $output = curl_exec($ch); echo $output; curl_close($ch);
From past use of the physical Curl command in Ubuntu it used to return that error when the path to the Image wasn't right, but i know its right as it works in Command line.
So is there anything I should change?
Additional Edit (To get it working)
I got it working how I wanted, but probably a lot more long winded than needed, but it works. I wrote a
CurlCommand.sh with the Curl command I wanted to execute, then called the
.sh file from a batch script (
CallCurlCommand.bat) opening Ubuntu and inserting the
CurlCommand.sh into it. Then using
PHP to call the batch file (
curl -X POST --data-binary '@/home/User/Pastec_FYP/Currency_Test_Images/Test_FiveEuro.jpg' 'http://localhost:4212/index/searcher'
I do still wish there was a straight conversion to PHP but this works.