1

Using PHP to run exiftool on an image.

My code is :

// $newEpoch is defined by user input
$date = date('Y:m:d G:i:s', $newEpoch);
shell_exec("exiftool '-DateTimeOriginal={$date}' '-FileModifyDate={$date}' '{$file}'");

This sets the DateTimeOriginal tag (Date Taken in Windows Explorer) perfectly, but it doesn't apply the FileModifyDate.

If I run exiftool '-FileModifyDate=someDate' someFilePath" in a terminal, it works perfectly.

So why won't the PHP do it ?

I have no errors in the logs...

EDIT :

PHP is running in docker (container is php:apache8.2), host is a Raspberry Pi 4 running Debian.

Silloky
  • 147
  • 13
  • This is way too vague, omitting lots of details. "_a terminal_" is not even an operating system - if one is _Windows_ then using apostrophes is wrong. – AmigoJack Aug 29 '23 at 21:20
  • Why aren't you checking the result of `shell_exec()`? Are you sure nothing is written to the error output? [Consider adding `2>&1`](https://www.php.net/manual/en/function.shell-exec.php#106250) **and** `echo`ing the result. – AmigoJack Aug 31 '23 at 15:49

0 Answers0