0

I am currently trying to display geolocation of images from a directory, I have managed to display a location for a single image however I'm not sure how to change the code so it reads several files opposed to one. Anyone know? Appreciate your responses.

$exif = exif_read_data("DSCN0010.jpg", 'ANY_TAG', true);

I have tried the following however this doesn't work

$exif = exif_read_data(".metadata images/", 'ANY_TAG', true);

2 Answers2

1

You can use the glob() function to get an array of filenames that match a pattern. For example, glob('images/*.jpeg') will return an array of all the JPEG files in the “images” directory. Then you can loop through the filenames and extract the EXIF data from each file.

Dexter
  • 7,911
  • 4
  • 41
  • 40
Chris H.
  • 41
  • 2
0

Use scandir to get array of files in the directory: http://php.net/scandir

And then use exif_read_data for each file individually.

Renka
  • 146
  • 9
  • function get_image_location($image = ''){ $dir = './metadata images'; $files1 = scandir($dir); $exif = exif_read_data("files1", 'ANY_TAG', true); this gives me an error – Gurps Singh Feb 19 '18 at 01:30
  • Warning: exif_read_data() expects parameter 1 to be a valid path, array given in – Gurps Singh Feb 19 '18 at 01:32
  • you neet to loop over the results of `scandir()` and read exif info one by one – Renka Feb 24 '18 at 13:27