Reputation: 625
When I call unlink
like so:
unlink($_FILES['upload_file']['tmp_name']);
I get the following error message:
unlink(): No such file or directory in /home/user/public_html/file.php on line 18, referer: http://localhost/file.php
I know I'm not exactly proficient in the language, but I checked the manual at http://www.php.net/manual/en/function.unlink.php and I seem to be using it right.
Upvotes: 0
Views: 588
Reputation: 47619
Seems that $_FILES['upload_file']['tmp_name']
does not exist. Try to print it to check is it correct path.
Anyway, You don't need delete tmp files, they will be deleted automatically.
Upvotes: 1
Reputation: 360572
Why are you trying to unlink an uploaded file? PHP will do it for you when the script handling the upload exits. This is default behavior - unless you take explicit steps to preserve the file, or PHP crashes hard, the uploaded files will ALWAYS be cleaned up for you.
Of course, if you're doing a move_uploaded_file()
or similar before you do the unlink, then the temporary file will no longer be there, which is why you're getting this error.
Upvotes: 1