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.
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
$zip->close();
$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.