I searched for working example to upload a file to a new installed nextcloud.
Can anybody provide some sample code?
I found one script usint sabre dav but this only results in App not installed
error.
Another script used curl_exec gets file not found
from nextcloud:
$fp = fopen("test.jpg", "r");
$c = curl_init();
curl_setopt($c, CURLOPT_URL, "https://mcloud.XXXX.at/index.php/s/fo7W3MMRnas9B3G");
curl_setopt($c, CURLOPT_USERPWD, "xxx:yyyy");
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
curl_setopt($c, CURLOPT_PUT, true);
curl_setopt($c, CURLOPT_INFILESIZE, filesize("test.jpg"));
curl_setopt($c, CURLOPT_INFILE, $fp);
$ret = curl_exec($c);
EDIT: with sabre DAV i also tested the following code without success:
include 'vendor/autoload.php';
$settings = array(
'baseUri' => 'https://XXXXXXXXXXXXXXX.at/remote.php/dav',
'userName' => 'test1',
'password' => 's8R87-JCZN6-tf3Eb-aHLyj-zPzKW'
);
$client = new Sabre\DAV\Client($settings);
// Upload a file
$upload_result = $client->request('PUT', 'test-upload.txt', 'This will be written to the txt file');
the result with sabre dav was always html response with "App not installed" message