How to change the behavior ZIP files are created

Nextcloud version (12):
Operating system and version (Debian 8):
Apache or nginx version (NGINX):
PHP version (7):

The issue you are facing:

Our project is using nextxloud as host for our downloads. Mainly we are hosting flashable ZIP files for Android.

It´s currently like this:
If we create a folder “Example” with our files and folders in it which are necessary and enter into this folder “Example”, it is possible to download the folder as ZIP file, by just sharing it and clicking on download in the upper right corner.
This is perfect, the problem we are facing is, that if the download is finished, the ZIP file “” contains the folder “Example” as first and only folder, only while entering it it´s possible to see the others.

What we need is the same behavior like if i put a dummy.txt file into the same folder and do not mark it, the ZIP file “” gets created but without the main folder “Example” in it. It immediately shows my files. But it´s not possible to create a dl link of this. Only the whole folder can be linked to download. Thats where my problem is.

I want the folder to be downloaded but not creating the Foldername as folder into the ZIP. But directly the files and subfolders.
That way it will be possible for us to edit and change only a few files while still be able to offer the whole flashable zip´s.
ATM we have to change the files on our PC´s and reupload the whole zip´s to the server. It´s really timeconsuming for a simple change of 1 File of 15kb to reupload a zip of 3GB.

I would be happy to get your help. I already searched manually but couldnt find the necessary files. Im sure it´s somewhere stated in the php´s and it should be a simple change to exclude /Example/…/ from it so it will be directly /…/

Thanks in advance

The function creating the zip-stream is here:


Thank you, i tried now several hours to change it by myself, sadly i seem to be really bad at it :smiley:
Anyone able to change it for me?

I again spent endless hours trying to solve it. But as im just a noobie beginner i can´t get this to work.
Is there maybe someone who can help me out on this?
I would really appreciate it it.
Thanks in advance

Hi @Eistee,

I’m no developer as well, so I can’t really help. But I would suggest you write down your attempts to fix this issue yourself, so that others can see what didn’t work so far or what was the result. Maybe someone with some experience in PHP can help and fix mistakes you made in your attempts.

Looking at the code and understanding it only a little bit, I would try the following changes.


public function addDirRecursive($dir, $internalDir='') {
		$dirname = basename($dir);
		$rootDir = $internalDir . $dirname;
		if (!empty($rootDir)) {


public function addDirRecursive($dir, $internalDir='') {
		$dirname = basename($dir);
		$rootDir = $internalDir . $dirname;
	/**	if (!empty($rootDir)) {
	*		$this->streamerInstance->addEmptyDir($rootDir);
	*	}

At least to me this looks like the root dir is put into the zip file at this point. So I would try to comment these lines out, hoping that this empty dir is not needed for some reason.

Good luck so far!

1 Like

@Schmu thanks for your attent to help. I appreciate it.
I also tried that already, i tried to go logical on this. It´s surely not possible to fix by commenting something out. I tried that with nearly every commit.
I´m hoping for someone to tell me the solution. I don´t think posting my wrong changes could help. I had over 180 files downloaded, so i made atleast 180 changes which didnt work. The one´s which didnt even generated a zip after aren´t included there.

I also looked in the file “apps/files_sharing/lib/Controller/ShareController.php” as it´s aswell related, but also there no success

Let’s ask @rullzer or @nickvergessen if they can help you.