如何删除已打开的文件?

发布于 2024-09-12 23:22:05 字数 90 浏览 2 评论 0原文

我正在使用 fopen 并将其保存到我的共享主机 /tmp 目录中。我关闭它,但 tmp 文件没有删除。我怎样才能删除这个?

PHP5,顺便说一句。

I'm using fopen and it's saving to my shared hosts /tmp directory. I fclose it, but the tmp file doesn't delete. How can I delete this?

PHP5, btw.

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

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

发布评论

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

评论(2

梨涡 2024-09-19 23:22:05

使用 unlink()

fclose 只是关闭流,不会执行任何操作文件本身。

Use unlink()

fclose just closes the stream, doesn't do anything to the file itself.

英雄似剑 2024-09-19 23:22:05

如果文件可通过 $_FILES 访问(HTTP 文件上传通常是这种情况),您可以使用 unlink($_FILES['userfile']['tmp_name']) 删除临时文件。请参阅:POST 方法上传

If the file is accessible via $_FILES (which is usually the case for HTTP file uploads), you can use unlink($_FILES['userfile']['tmp_name']) to delete the temporary file. See: POST method uploads

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