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">
</form>
<?php
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, "http://domain.com/owncloud/remote.php/webdav/");
curl_setopt($ch,CURLOPT_HTTPHEADER,'Authorization: Basic');
curl_setopt($ch,CURLOPT_USERPWD, "user:password");
curl_setopt($ch,CURLOPT_PUT, 1);
curl_setopt($ch,CURLOPT_POSTFIELDS,$data);
$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'];
}else{
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.
Regards