title: Curl and posting base64 data to a php uploading script
body: <p>I'm looking to make a script to upload images from my server to an imagehost, which has a php API.</p>
  
  <p>I'm supposed to send the following html request to the API:</p>
  
  <pre><code>http://example.com/api?upload=myImg&amp;key=apiKey&amp;format=xml
  </code></pre>
  
  <p>myImg and apiKey respectively are the the image and the key, but you probably have guessed that :)</p>
  
  <p>My code is:</p>
  
  <pre><code>curl -X POST http://example.com/api?upload="$apiImg"&amp;key="$apiKey"&amp;format=xml
  </code></pre>
  
  <p>When I use an remote URL as the image, it works fine.</p>
  
  <p>However, to upload a local image, it has to be base64 encoded; I did that by doing:</p>
  
  <pre><code>apiImg=$(base64 "$1") #my script takes the image as argument
  </code></pre>
  
  <p>But this gives me curl errors (too many arguments)</p>
  
  <p>What am I supposed to do here ? I'm totally lost as how to send this base64 data to the server...</p>
  
  <p>Thanks in advance :)</p>