PHP tmp 文件夹?

发布于 2024-12-28 13:23:33 字数 289 浏览 1 评论 0原文

我正在练习使用 PHP 上传文件,并且多次上传文件,因此我想确保没有占用服务器上的大量空间。我用 while 循环检查了 php tmp 目录中的每个文件,有 103,988 个条目。

这比正常情况多吗?我假设 tmp 目录用于存放在一段时间后自动删除的文件。我应该如何管理这个文件夹?

我问这个问题的部分原因是因为我正在编写一个应用程序,该应用程序需要用户文件,更改一些内容,然后将其返回给他们。我希望他们离开后删除该文件,但我不确定最好的方法是什么。我是否应该有一个文件夹来放置所有文件并使用 cron 删除早于特定时间的文件?

I'm practicing some file upload with PHP and I was uploading a file numerous times, so I wanted to make sure I wasn't taking up a lot of space on the server. I had a while loop go over every file in the php tmp directory, and there were 103,988 entries.

Is this more than normal? I had assumed the tmp directory was for files that were automatically deleted after a certain amount of time. Am I supposed to be managing this folder some how?

Part of the reason I ask is because I'm writing an app that takes a users file, changes some things, and serves it back to them. I want the file to be deleted once they leave, but I'm not sure what the best way to do it is. Should I have a folder I put all the files in and use cron to delete files older than a certain time?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

渡你暖光 2025-01-04 13:23:33

一般规则是,您应该尽可能自行清理。

如果您不确定每次是否可以删除临时文件,最好让 cron 作业偶尔为您执行此操作。

General rule is that you should clean up after yourself whenever possible.

If you aren't sure that you can remove temporary files every time, it is a good idea to have a cron job doing this for you once in a while.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文