i've been trying to troubleshoot this for a long time now and I can't figure it out 😢
Purpose: To make a gzipped tarball of a directory. Please look at the 2nd bit of code, thats where the problem is. Whenever I change the path of the find directory, it doesn't work properly even after I checked the find's results and they are correct. The problem happens when making the tar.gz, like stated below it creates an empty archive instead.
<?php
/* This Works Fine */
/* finds any jpg or jpegs in the current working directory and makes a gzip tarball of it. */
$cmd = "tar -cvf backup.tar.gz `find . -iregex '.*\.\(jpg\|jpeg\)' -maxdepth 1`";
exec($shellLine, $output, $returnCodes);
/* This Does Not Work, it puts an emtpy gzip tarball thats app. 10k in the directory */
/* The only thing thats diff here is i change the find to look in a subdirectory */
$cmd = "tar -cvf backup.tar.gz `find './foobarDir/' -iregex '.*\.\(jpg\|jpeg\)' -maxdepth 1`";
exec($shellLine, $output, $returnCodes);
?>