Entry name too long

Now I have Zip working in PHP, I have an error which I can’t make sense of.
Usually errors are self explanitory or can be explained by searching for it, but this one has me stumped.

The error is coming from this method:-

		private function dozip(){
			// Format the document
			$filebody = $this->formatXml($this->xml);
			// Do ZIP file
			$zip = new ZipArchive();
			if (!$zip->open($this->filename, ZipArchive::OVERWRITE)) {
				return false ;
			$zip->addFromString("buoys.kml", $filebody);
			$zip->addPattern('/\.(?:png)$/', $this->idir); // Line 162
			$this->msg = htmlentities($filebody) ;
			return $filebody ;

I’m basically adding all the PNG files (icons) from a folder to the archive. But I don’t understand what it is telling me is “too long”. The same script worked fine in PHP7, but in 8 I’m getting the error.

a filepath can be too long. What is idir? You dont show us a definition for that value.

EDIT: Okay, It’s buried in the image. Gotcha.

The system appears to be saying that it got a really insanely long filepath, which… doesnt make a lot of sense unless you’re executing this on a directory with potentially looping directory shortcuts?

Yes, the value of idir is in the error image: 'files/icons/'
It’s just a regular folder containing 53 PNG images. Their filenames are not excessively long, probably no more than about 16 characters.
So I’m confused.


$zip->addPattern('/\.(?:png)$/', $this->idir,['remove_all_path' => true]);

1 Like

That worked, thank you.
But I’m still confused as to why it was failing with that error, when it worked in PHP7.

Not sure. remove_all_path will just turn “/this/is/a/directory/files/icons/name.png” into “name.png”, so i dont know what would cause the problem.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.