开发者

How long do uploaded files stay on your server?

When I use a form to upload a file, it gives me the 'name' and 'tmp_name' and you're supposed to move the file from its temporary location in order to keep it. But how long does the file stay on the server before it gets deleted? Is it stored there permanently until you manually clean up your folders, or does it get deleted once the PHP script it was submitted too is finished running? My form spans over multiple pages and I wan开发者_运维知识库ted to just process everything at the end rather than processing parts after each page of the form is completed. The upload is in step 3 of 5 so I was wondering if I saved the uploaded file information from step 3, if the file would still be there when the form is finished after step 5.


Unless PHP dies a horrible flaming death, or you take steps to preserve the file, it'll be auto-killed by PHP when the script exits. If you need to preserve it through a multi-stage form, you'll have to move it somewhere safe, and then keep track of it (hidden form fields, session, database, etc...) and implement your own cleanup system to handle orphaned files from abandoned forms.


it get deleted once the PHP script it was submitted too is finished running

so, you can either make file upload as last step or implement your own garbage collector for the unfinished forms.


It depends on the tmp upload folder. If it is the tmp directory, you can't really trust it to live to step 5. If you control the upload folder, then you could reliably trust it to live to step 5. You can set the upload path with upload_tmp_dir

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜