[請益] Is it possible to trigger a php file at the moment the

看板PHP作者 (自由人371)時間8年前 (2017/07/30 03:58), 編輯推噓2(202)
留言4則, 2人參與, 最新討論串1/1
For example, if a user is accessing an image file on my server, is it possible to execute another PHP file at the same time? I want to record the ip, HTTP_USER_AGENT and HTTP_ACCEPT_LANGUAGE of the users who have accessed this image file. The difficult point is how to execute (or may say “trigger”) that PHP recording file at the time the user is accessing the image. I know I can read the content of the image to the PHP first then output it as an image and record the user's information meanwhile, but this method may occupy so much memory usage when the size of the image file is very large. For this reason, is it possible to make the user access the image file directly but also can trigger another PHP file at the same time? -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 203.136.205.31 ※ 文章網址: https://www.ptt.cc/bbs/PHP/M.1501358330.A.5B9.html

07/30 12:33, , 1F
header('Location: /web/path/to/file.jpg');
07/30 12:33, 1F

07/30 15:36, , 2F
does this work when the file is covered by redirect
07/30 15:36, 2F

07/30 15:37, , 3F
rule in .htaccess?
07/30 15:37, 3F

07/30 16:15, , 4F
you need to do some "trick" to avoid infinte loop.
07/30 16:15, 4F
文章代碼(AID): #1PVEZwMv (PHP)
文章代碼(AID): #1PVEZwMv (PHP)