作者freeman371 (自由人371)
看板PHP
标题[请益] Is it possible to trigger a php file at the moment the
时间Sun Jul 30 03:58:47 2017
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://webptt.com/cn.aspx?n=bbs/PHP/M.1501358330.A.5B9.html
1F:推 MarcoReus: header('Location: /web/path/to/file.jpg'); 07/30 12:33
2F:→ MOONRAKER: does this work when the file is covered by redirect 07/30 15:36
3F:→ MOONRAKER: rule in .htaccess? 07/30 15:37
4F:推 MarcoReus: you need to do some "trick" to avoid infinte loop. 07/30 16:15