php unlink() not found
When I call unlink
like so:
unlink($_FILES['upload_file']['tmp_name']);
I get t开发者_运维百科he 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.
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.
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.
精彩评论