This Answer relates to the first version of the Question, and I don’t know how to updated it, I’ll leave it here as general reference.
Don’t use a plugin folder (or a theme) for this. Maybe your plugin doesn’t have an Upgrade feature and nothing will be overwritten. But the best practice is to use a folder in /wp-content
root or inside /wp-content/uploads
.
In /wp-content/my-images
:
$test = glob( WP_CONTENT_DIR . '/my-images/*.png');
In /wp-content/uploads/my-images
:
$up_dir = wp_upload_dir();
$test = glob( $up_dir['basedir'] . '/images/*.png');