Running File Existence Automatic Script

I have a little form displayed as popup (Quick Dialog extension).

In the form, I have a file field that can be filled by the user manually or to be automatically filled when a file is present in a directory (the file will be pushed through another way - user has the choice).

So, I want to know if there is an extension (I’ve already looked for) or a way to achieve the automatic filling when the file appears in the directory…

Many thanks for your support!