tags:

views:

57

answers:

2

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.

+1  A: 

Use unlink()

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

NullUserException
I can't unlink it becuase I don't know what it's been downloaded as
Shamoon
@Shamoon So how can you fopen it? Use the same path and filename for unlink as you did with fopen
NullUserException
No can do.. the path is not on my server.. it's http://www.somesite.com/file.txt.gz
Shamoon
A: 

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

Fraxtil
It's not a POST upload.. I'm doing one of these:$url = "http://www.somesite.com/file.txt.gz";$handle = fopen( "compress.zlib://$url", "r" );
Shamoon