I have a function which I use to enable downloading of files from a non-public directory. The downloading part works fine except that it does not prompt the user before and allo
i am not sure if this is really a php thing, i believe it´s more based on the browser settings. in general your code looks okay for me, when i compare it with other examples.
To stop Automatic downloads in chrome goto content setting which is chrome://settings/content
Then scroll to the bottom and your see the Automatic Downloads bit, then select your preference.
P.S Not really a question suited for Stackoverflow.