Trying to develop a webForm with html-php-curl


Hey there,

I'm trying to develop a webform to allow me and my users to upload files to a specific folder through a html form using php and curl, but when I try to upload a file the server returns the message

Sabre\DAV\Exception\Conflict PUT is not allowed on non-files.

I don't know if I have to declare something extra in my code:

<form  action="cr.php" method="post" enctype="multipart/form-data">
    <input type="file" name="upload" />
    <input type="submit" value="Upload the file">


if ($_FILES['upload']['tmp_name']){
    // for debugin purposes echo $_FILES['upload']['tmp_name'] ;
    $ch = curl_init();
    $cfile = new CURLFile ($_FILES['upload']['tmp_name'],$_FILES['upload']['type'],$_FILES['upload']['name']);
    $data = array ("upload"=>$cfile);
    curl_setopt($ch,CURLOPT_URL, "");
    curl_setopt($ch,CURLOPT_HTTPHEADER,'Authorization: Basic');
    curl_setopt($ch,CURLOPT_USERPWD, "user:password");
    curl_setopt($ch,CURLOPT_PUT, 1);
    $subida = curl_exec($ch);
        if($subida == true){
                echo "<br>";
                echo "The file was uploaded <br>";
                echo "File data:<br>".$_FILES['upload']['tmp_name']."<br>".$_FILES['upload']['type']."<br>".$_FILES['upload']['name'];

            echo "Error: " . curl_error($ch);



I was trying to use PUT to upload files too but the method wasn't supported by ownCloud.

Please help me to solve this.

Necesito hacer un formulario web para subir archivos


you might find a lot of infos what you're doing wrong (using PUT to remote.php/webdav/ instead of remote.php/webdav/filename.jpg) at this thread:


I've already checked the post but I'm a bit confused, I'm new to this type of scripting and the code posted on your reference seems to a comand line upload through curl, so can you guide me a bit to how to port that code to php? because my objective is make a html form to be published on web.

Thanks for your answer.

Necesito hacer un formulario web para subir archivos


for porting such stuff to PHP its probably better to ask on a forums dedicated to PHP programming.