title: Uploading Files to an owncloud using curl
body: <p>I have written an Application, should upload some files to several mobile devices. By now, I am using dropbox, I have an App (<a href="https://www.dropbox.com/developers" rel="nofollow noreferrer">https://www.dropbox.com/developers</a>), so I can upload any data to the clients Dropbox. </p>
  
  <p>Now I would like to switch to owncloud because of some security concerns. I already have read this:
  <a href="https://stackoverflow.com/questions/24758167/uploading-files-to-an-owncloud-server-programatically">Uploading files to an ownCloud server programatically</a></p>
  
  <p>But unfortunately it didn't help.</p>
  
  <p>I tried </p>
  
  <pre><code>curl -X PUT -u username:password "http://myserver.com/owncloud/remote.php/webdav/test" -F f=@"/tmp/test"
  </code></pre>
  
  <p>The file was uploaded, but there was a Problem: Some kind of Header was added to my file.</p>
  
  <p>Original test-file:</p>
  
  <blockquote>
    <p>test</p>
  </blockquote>
  
  <p>Uploaded File:</p>
  
  <blockquote>
    <p>--------------------------00c5e21306fd0b2d Content-Disposition: form-data; name="f"; filename="test" Content-Type:
    application/octet-stream</p>
    
    <p>Dies ist ein Test.</p>
    
    <p>--------------------------00c5e21306fd0b2d--</p>
  </blockquote>
  
  <p>While this is really annoying on any text-Files it is a desaster on any binary files like JPGs etc, because they can't be opened any more after uploading.</p>
  
  <p>That's why, I tried the other possible way, which was described:</p>
  
  <pre><code>mischka@lappy:/tmp$ curl -X PUT -u 'username:password' "http://myserver/owncloud/remote.php/webdav/test" --data-binary @"/tmp/test"
  &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;d:error xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns"&gt;
    &lt;s:exception&gt;Sabre\DAV\Exception\BadRequest&lt;/s:exception&gt;
    &lt;s:message&gt;expected filesize 19 got 0&lt;/s:message&gt;
  &lt;/d:error&gt;
  </code></pre>
  
  <p>But the result was even worse!</p>
  
  <p>Can anyone tell me, what I am doing wrong?</p>