Unlink problem

Alright I am a total PHP noob, so bare with me :stuck_out_tongue:

OK I’m using PHP to delete a file specified in a flash app (Sorry but I can’t show you it :(), the code is extremely simple (I’ve cut out the code thats unrelated):

<?php
	echo (unlink ($_POST ['file']));
?>

OK the problem is, once the file is deleted a new file is appears, with a name such as ā€˜.nfs37260B3’ which is deleted within a few seconds. Unfortunately the app refreshes the contents of the folder as soon as the delete if complete, so the new file appears on the list. Is this a temporary file made in order to delete the file :h:

Anyway the problem only seems to occur once tested on the server, on my machine it seems to work fine. Well either that or the new file disappears before the contents of the folder are refreshed :confused:

Any help appreciated.

What operating system are you using? I think you are right about this temporary file being using by the operating system’s file-system in the process of deleting the file.

A simple solution that comes to mind is to only search the directory for normal files. (EG: Those that have characters before and after a dot.) A simple regular expression to do this would be: ā€œ.+…+ā€

Looks like it’s using [w]NFS[/w]. It will create temporary files sporadically to do random stuff, and there’s not really anything you can do to avoid it except not use NFS to mount your files. Googling for ā€œnfs filesā€ finds a lot of information regarding them, but essentially everything comes to the same conclusion. Just ignore them.

To hide hidden files (Esh is correct in that hidden files are prefixed with a dot), you could also use this regular expression: [font=monospace]^[^.][/font], which unlike Esh’s, actually works. :stuck_out_tongue:

Thanks alot I’ll try it now :smiley:

:lol: Ouch, that kind of hurt. But yeah, I didn’t even bother testing that Regex because I suspected that someone with much more Regex knowledge (I read Mastering Regular Expressions about a year ago (It’s the 1996/1997 edition.) but still don’t feel like a Regex Master.) would come in here with a much better solution.

I just took a sec to actually test my regular expression and it does work. :to:


  1. ^. ā†©ļøŽ

[QUOTE=Esherido;2355159]I just took a sec to actually test my regular expression and it does work. :to:[/QUOTE]

No it doesn’t. It should do the opposite on these cases:

[list][].filename.extension (should be hidden)
[
]valid_filename (shouldn’t be hidden)[/list]

Plus, it’s stupidly complicated.

:stuck_out_tongue:

The too reasons you stated are inconsequential because I choose to ignore them. Besides, my solution is more simple than your solution. :stuck_out_tongue:

Err … whatever.

:lol: For once I win an argument against the mighty Jeff.

I disagree; you lost. He just didn’t want to reply to you. That’s how bad your response was. :slight_smile:

:lol: Actually, it was that great, he was just dumbfounded by my knowledge.