Hi Ian,
Not sure if this will help as my HV failed and haven't replaced it and was not using PHP7, but I worked with morfeas2002 on that script and it worked fine for me - even though I didn't understand the code.
In comparing your attached script to mine I see some differences:
Your line 11: $dir = "../FI9901EP_00626E70E4DF"; // change to suit your system relative to where this script is executed
Mine line 15: $dir = "../hvipupload"; // change to suit your system relative to where this script is executed
and that should be fine.
Your line 20: if (preg_match('/^\.{1,2}$/',$fname)) continue;
Mine line 25: if (ereg('^\.{1,2}$',$fname)) continue;
Your line 22: if (! preg_match('/\.(JPG)$/',$fname)) continue;
Mine line 27: if (! ereg($pattern,$fname)) continue;
and the above 2 differences could be PHP 7 requirement
Your line 41: copy("/snap/$newname", "/new/webcamimage.jpg"); // change to suit your system relative to where this script is executed
Mine line 50: copy("../hvipupload/$newname", "../hvipimage/hvipimage.jpg"); // change to suit your system relative to where this script is executed
where my defined $dir = "../hvipupload" in line 15 is used in line 50, your line 41 is different than in line 11
My webserver structure was?
/pictures/hvip/hik.php (my name change script)
/pictures/hvipupload/ (where the date/time stamped image was FTP and which was emptied at each run of the rename script)
/pictures/hvipimage/hvipimage.jpg (the renamed current time image)
Darn, I wish that camera still worked
http://www.komokaweather.com/pictures/hvipimage/hvipimage.jpgEnjoy,
Paul
EDIT: after I typed my reply and posted I noticed you had also posted my script in full