Ajax.php controller: elevationprofilebysegments endpoint -- added an explicit check of permissions on the directory where chart images are saved.

JPGraph's failure mode is to generate a PNG and spit it out, which isn't very useful to AJAX endpoints expecting to receive an URL or else a text error message.