What is the best way to upload a temporary & sensitive file and then delete it when done

I was facing the same issue and finally wrote some code, you will find the source code here. https://github.com/HeyMehedi/Temporary-File-Manager

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)