当会话将在php中销毁时销毁文件
当会话销毁时是否可以从文件夹中删除文件。当用户进入网站时,他可以上传文件(图像或文本文件)等,而无需登录网站。文件将存储到我的项目的文件夹中。现在我需要做的是,如果用户在未登录的情况下退出浏览器,我需要删除他上传到项目文件夹中的所有文件。怎么办?
提前致谢。
is it possible to remove files from the folder when session will destroy. am doing that when a user come into the site and he can upload files(images, or textfiles), etc.. with out login into the site. and the files 'll store into my project's folder. now i need to do if the user quits from browser with out login i need to delete all the files what he upload in to project folder. how to do this ?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
发布评论
评论(5)
~没有更多了~
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
您可以通过实现自己的会话处理程序来做到这一点。这样,您可以为各种事件定义回调,包括会话的销毁。有关详细信息,请参阅此链接:
http://www.php.net/manual/en/function.session-set-save-handler.php php.net/manual/en/function.session-set-save-handler.php
更新: 该解决方案的问题是您需要实现会话处理代码的其余部分以及(初始化会话、关闭会话、读取来自存储、写入、垃圾收集)。但是,上面的链接页面提供了一个完整的示例,您可以向其中添加功能。
You can do this by implementing your own session handler. This way, you can define a callback for various events, including the destruction of a session. See this link for more information:
http://www.php.net/manual/en/function.session-set-save-handler.php
Update: The problem with that solution is that you need to implement the rest of the session handling code as well (initialize the session, close the session, read from storage, write, garbage collect). However, the linked page above gives a full example that you can add your functionality to.