Use CURL to upload files to OC



I am trying to upload tarballs to OC via a script. The script first compresses files on the local server and after that I want to create a directory on OC and push the tarballs there.
The problem is that CURL fails, because does not exist.. What else can this be?

I am using this documentation:

Any help is much appreciated!

Trying to develop a webForm with html-php-curl


then you have some more serve issues within your environment or your webserver itself. A FAQ describing some of these issues and possible solutions are available here:


Not sure what error you are experiencing but the correct way to do this is e.g. like that (of course skip cookie if you are not using XDebug in PHP Storm):

Please also mind that, that to PUT file into the directory, the directory has to exists. You need to use webdav function MKCOL similar way.

If you need, there is Python library doing that:


Thanks for your reply.. I'm getting there because I can now remotely create directory's. The last step would be to upload my tar.gz files to the folder I've created. This error shows up while trying to upload a file:

> <?xml version="1.0" encoding="utf-8"?>
> <d:error xmlns:d="DAV:" xmlns:s="">
>   <s:exception>Sabre\DAV\Exception\Conflict</s:exception>
>   <s:message>PUT is not allowed on non-files.</s:message>
> </d:error>

Your script looks good though, so maybe that'll solve my problems!


PUT works on endpoint, it means that the final path has to be file.

curl -X PUT -u $user:$pass --data-binary @"$testfile2" "http://$server/remote.php/webdav/test/zombie.jpg"

This will mean that your ownCloud address is "", endpoint is "remote.php/webdav", the file will be in the folder "test", and filename is "zombie.jpg".

PUT is not allowed on non-files means that you are trying to PUT (update) a non-file e.g. folder.


Just stumbled over:

Wasn't aware that this is even documented :slight_smile:


Thanks for your input guys, my issue is fixed and I'm able to upload via CLI now :slight_smile: