Uploading a file to ownCloud through PHP and a HTML Form
<p>I'm having some troubles trying to develop a webapp for uploading files to my owncloud server trough a form using PHP, I'm using curl to PUT a request through the webDav, so here's the code:</p>

<p>Index.php</p>

<pre><code>&lt;html&gt;
        &lt;head&gt;
            &lt;title&gt;Theform is here&lt;/title&gt;
        &lt;/head&gt;
        &lt;body&gt;
            &lt;div align="center"&gt;
                &lt;h1&gt; File uploads with OwnCloud API&lt;/h1&gt;
                &lt;form method="post" action="uploader.php" name="fileuploader"&gt;
                    &lt;label&gt;Select a File to upload&lt;/label&gt;&lt;br&gt;
                    &lt;input type="file" name="file"&gt;&lt;/input&gt;&lt;br&gt;
                    &lt;input type="submit" value="upload file"&gt;&lt;/input&gt;
                &lt;/form&gt;
                &lt;?php
                ?&gt;
            &lt;/div&gt;
        &lt;/body&gt;
    &lt;/html&gt;
</code></pre>

<p>uploader.php</p>

<pre><code>&lt;?php
    $request = curl_init('http://mydomain.cl/owncloud/remote.php/webdav/Dev/');

    curl_setopt($request,CURLOPT_POST,true);
    curl_setopt($request,CURLOPT_HTTPHEADER,'Authorization: Basic');
    curl_setopt($request, CURLOPT_USERPWD, "user:password");
    curl_setopt($request, CURLOPT_PUT, 1);
    curl_setopt(
        $request,
        CURLOPT_INFILE,
        array(
            'thefile'=&gt;
                        '@'            .$_FILES['file']['tmp_name']
                        . ';filename=' .$_FILES['file']['daName']
                        . ';type='     .$_FILES['file']['type']

        ));
    curl_setopt($request, CURLOPT_INFILE, $_FILES['file']);
    curl_setopt($request, CURLOPT_INFILESIZE, filesize($_FILES['file']));


    // output the response
    curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($request, CURLOPT_BINARYTRANSFER, TRUE); 
    echo curl_exec($request);

    // close the session
    curl_close($request);

?&gt;
</code></pre>

<p>When I try to upload the file I get this response:</p>

<blockquote>
  <p>Sabre\DAV\Exception\NotAuthenticated No 'Authorization: Basic' header
  found. Either the client didn't send one, or the server is
  mis-configured</p>
</blockquote>

<p>But when I use the owncloud Client I can access to my files without problems.</p>

<p>EDIT: Corrected the name variable $ch to $request and added the line :</p>

<blockquote>
  <p>curl_setopt($request,CURLOPT_HTTPHEADER,'Authorization: Basic');</p>
</blockquote>

<p>from @Craig post, after that I got this error message:</p>

<blockquote>
  <p>Sabre\DAV\Exception\Conflict PUT is not allowed on non-files. </p>
</blockquote>

<p>Please help me to solve this. Regards :D</p>