的PHP :: TMP文件停留多长时间? [英] php:: how long to tmp files stay?

查看:197
本文介绍了的PHP :: TMP文件停留多长时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理一个上传脚本.

I am working on an upload script.

如果用户上传了一个文件并且该文件已经存在,我想警告该用户(全部通过ajax),并为他们提供替换或取消文件的选项.

If a user uploads a file and it already exists I want to warn the user (this is all through ajax) and give them the option to replace it, or cancel.

与其移动文件, 我很好奇我是否可以将文件保留在tmp中,并在ajax响应中将路径传递回该文件.

Instead of moving the file, I was curious if I could just leave the file in tmp and pass back the path to that file in the ajax response.

如果用户说要在该ajax请求中覆盖旧文件,则将路径传递回php,该文件将继续在该文件上运行.

If they user says overwrite the old file in that ajax request pass the path back to php which continues to work on the file.

要使其正常工作,我需要知道文件在php的tmp目录中保留了多长时间

For this to work however I need to know how long a file stays in php's tmp dir

推荐答案

通过POST上传的文件将在php脚本执行完毕后立即删除.

Files uploaded through POST are deleted right after php script finishes its execution.

根据 php.net : 如果文件没有被移走或重命名,则该文件将在请求结束时从临时目录中删除."

According to php.net: "The file will be deleted from the temporary directory at the end of the request if it has not been moved away or renamed."

这篇关于的PHP :: TMP文件停留多长时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆