How do I delete a file that's been fopen'd?
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.
Use unlink()
fclose just closes the stream, doesn't do anything to the file itself.
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
精彩评论